aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2010-09-30 01:28:20 +0200
committerStefan Monnier2010-09-30 01:28:20 +0200
commita01a7932080e8a6e7bc8472c58cefabcc2c37df3 (patch)
tree94b28b19c8f1536e76ffe7d5826811b74a79e3a5 /src
parentcc390e46c7ba95b76ea133d98fd386214cd01709 (diff)
parent6b0f7311f16646e0de2045b2410e20921901c616 (diff)
downloademacs-a01a7932080e8a6e7bc8472c58cefabcc2c37df3.tar.gz
emacs-a01a7932080e8a6e7bc8472c58cefabcc2c37df3.zip
Merge from trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog.104
-rw-r--r--src/ChangeLog.52
-rw-r--r--src/ChangeLog.72
-rw-r--r--src/ChangeLog.813
-rw-r--r--src/ChangeLog.trunk844
-rw-r--r--src/Makefile.in12
-rw-r--r--src/alloc.c92
-rw-r--r--src/bidi.c126
-rw-r--r--src/buffer.c97
-rw-r--r--src/buffer.h2
-rw-r--r--src/callproc.c4
-rw-r--r--src/casefiddle.c4
-rw-r--r--src/ccl.c8
-rw-r--r--src/character.c86
-rw-r--r--src/character.h21
-rw-r--r--src/charset.c2
-rw-r--r--src/cmds.c33
-rw-r--r--src/coding.c7
-rw-r--r--src/commands.h2
-rw-r--r--src/composite.c34
-rw-r--r--src/composite.h13
-rw-r--r--src/config.in9
-rw-r--r--src/data.c11
-rw-r--r--src/dbusbind.c236
-rw-r--r--src/deps.mk1
-rw-r--r--src/dispextern.h60
-rw-r--r--src/dispnew.c41
-rw-r--r--src/doc.c40
-rw-r--r--src/doprnt.c16
-rw-r--r--src/editfns.c141
-rw-r--r--src/emacs.c12
-rw-r--r--src/eval.c10
-rw-r--r--src/fns.c139
-rw-r--r--src/font.c2
-rw-r--r--src/frame.c23
-rw-r--r--src/frame.h2
-rw-r--r--src/ftfont.c76
-rw-r--r--src/gnutls.c539
-rw-r--r--src/gnutls.h62
-rw-r--r--src/gtkutil.c6
-rw-r--r--src/image.c2
-rw-r--r--src/indent.c12
-rw-r--r--src/insdel.c5
-rw-r--r--src/intervals.c122
-rw-r--r--src/intervals.h24
-rw-r--r--src/keyboard.c70
-rw-r--r--src/keyboard.h2
-rw-r--r--src/lisp.h105
-rw-r--r--src/lread.c20
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/marker.c70
-rw-r--r--src/minibuf.c10
-rw-r--r--src/print.c59
-rw-r--r--src/process.c282
-rw-r--r--src/process.h24
-rw-r--r--src/region-cache.c83
-rw-r--r--src/region-cache.h12
-rw-r--r--src/s/aix4-2.h4
-rw-r--r--src/s/bsd-common.h1
-rw-r--r--src/s/cygwin.h10
-rw-r--r--src/s/darwin.h9
-rw-r--r--src/s/gnu-linux.h4
-rw-r--r--src/s/hpux10-20.h6
-rw-r--r--src/s/template.h12
-rw-r--r--src/s/usg5-4-common.h5
-rw-r--r--src/scroll.c18
-rw-r--r--src/search.c107
-rw-r--r--src/syntax.c66
-rw-r--r--src/syntax.h4
-rw-r--r--src/term.c166
-rw-r--r--src/termhooks.h6
-rw-r--r--src/textprop.c42
-rw-r--r--src/undo.c16
-rw-r--r--src/w32.c381
-rw-r--r--src/w32fns.c4
-rw-r--r--src/w32proc.c7
-rw-r--r--src/window.c26
-rw-r--r--src/xdisp.c392
-rw-r--r--src/xgselect.c6
-rw-r--r--src/xml.c145
-rw-r--r--src/xrdb.c2
-rw-r--r--src/xterm.c158
82 files changed, 3526 insertions, 1808 deletions
diff --git a/src/ChangeLog.10 b/src/ChangeLog.10
index dd847f8a64e..393c7bdf8dc 100644
--- a/src/ChangeLog.10
+++ b/src/ChangeLog.10
@@ -6914,7 +6914,7 @@
6914 6914
6915 * search.c (search_buffer): Give up BM search on case-fold-search 6915 * search.c (search_buffer): Give up BM search on case-fold-search
6916 if one of a target character has a case-equivalence of different 6916 if one of a target character has a case-equivalence of different
6917 charset even if that target charcter is an ASCII. 6917 charset even if that target character is an ASCII.
6918 6918
6919 * casefiddle.c (casify_object): Fix for the case that case 6919 * casefiddle.c (casify_object): Fix for the case that case
6920 conversion change the byte length. 6920 conversion change the byte length.
@@ -21089,7 +21089,7 @@
21089 21089
21090 * w32.c (g_b_init_is_windows_9x, g_b_init_open_process_token) 21090 * w32.c (g_b_init_is_windows_9x, g_b_init_open_process_token)
21091 (g_b_init_get_token_information, g_b_init_lookup_account_sid) 21091 (g_b_init_get_token_information, g_b_init_lookup_account_sid)
21092 (g_b_init_get_sid_identifier_authority ): Add several static 21092 (g_b_init_get_sid_identifier_authority): Add several static
21093 global variables. 21093 global variables.
21094 21094
21095 * w32.c (globals_of_w32): New function. Used to initialize those 21095 * w32.c (globals_of_w32): New function. Used to initialize those
diff --git a/src/ChangeLog.5 b/src/ChangeLog.5
index 9be45e2fc54..cc3fcdd88f2 100644
--- a/src/ChangeLog.5
+++ b/src/ChangeLog.5
@@ -4093,7 +4093,7 @@
4093 4093
4094 * xterm.h: Delete X10 code. 4094 * xterm.h: Delete X10 code.
4095 4095
4096 * xfns.c (Fx_create_frame): Don't increment refernce_count 4096 * xfns.c (Fx_create_frame): Don't increment reference_count
4097 until the frame is put on the frame list. 4097 until the frame is put on the frame list.
4098 4098
4099 * xterm.c (x_initialize): Init x_noop_count, x_focus_frame 4099 * xterm.c (x_initialize): Init x_noop_count, x_focus_frame
diff --git a/src/ChangeLog.7 b/src/ChangeLog.7
index 6cc3d0f9e3e..7421aba4403 100644
--- a/src/ChangeLog.7
+++ b/src/ChangeLog.7
@@ -1040,7 +1040,7 @@
1040 1040
1041 * lread.c: Remember the last TWO strings skipped with #@. 1041 * lread.c: Remember the last TWO strings skipped with #@.
1042 (prev_saved_doc_string*): New variables. 1042 (prev_saved_doc_string*): New variables.
1043 (Fload): Initalize prev_saved_doc_string. 1043 (Fload): Initialize prev_saved_doc_string.
1044 (read1): Copy saved_doc_string to prev_saved_doc_string 1044 (read1): Copy saved_doc_string to prev_saved_doc_string
1045 before storing a new string in saved_doc_string. 1045 before storing a new string in saved_doc_string.
1046 (read_list): Look in prev_saved_doc_string as well as 1046 (read_list): Look in prev_saved_doc_string as well as
diff --git a/src/ChangeLog.8 b/src/ChangeLog.8
index 4dd3d0dd071..5033a055576 100644
--- a/src/ChangeLog.8
+++ b/src/ChangeLog.8
@@ -10392,7 +10392,7 @@
10392 * term.c (get_char_info): Use WHAT field of CHAR_INFO. 10392 * term.c (get_char_info): Use WHAT field of CHAR_INFO.
10393 Use tabs as multiples of spaces. 10393 Use tabs as multiples of spaces.
10394 10394
10395 * dispextern.h (struct char_info ): WHAT field. 10395 * dispextern.h (struct char_info): WHAT field.
10396 10396
10397 * term.c (encode_terminal_code): Don't use GLYPH_CHAR, use 10397 * term.c (encode_terminal_code): Don't use GLYPH_CHAR, use
10398 FAST_GLYPH_CHAR instead because GLYPH_CHAR won't remove faces. 10398 FAST_GLYPH_CHAR instead because GLYPH_CHAR won't remove faces.
@@ -10407,8 +10407,7 @@
10407 10407
10408 * xterm.c (XTget_char_info): Check WANT_ELLIPSIS_P. 10408 * xterm.c (XTget_char_info): Check WANT_ELLIPSIS_P.
10409 10409
10410 * dispextern.h (struct char_info ): GLYPH_ROW for intermediate 10410 * dispextern.h (struct char_info): GLYPH_ROW for intermediate glyphs.
10411 glyphs.
10412 10411
10413 * dispnew.c (init_char_info): Init GLYPH_ROW to NULL. CHAR_CURSOR 10412 * dispnew.c (init_char_info): Init GLYPH_ROW to NULL. CHAR_CURSOR
10414 moved to xdisp.c. 10413 moved to xdisp.c.
@@ -10436,7 +10435,7 @@
10436 10435
10437 * term.c (get_char_info): Set MAX_PIXEL_WIDTH in CHAR_INFO. 10436 * term.c (get_char_info): Set MAX_PIXEL_WIDTH in CHAR_INFO.
10438 10437
10439 * dispextern.h (struct char_info ): Use LISP_CHAR_TABLE for DP. 10438 * dispextern.h (struct char_info): Use LISP_CHAR_TABLE for DP.
10440 New member MAX_PIXEL_HEIGHT. 10439 New member MAX_PIXEL_HEIGHT.
10441 10440
10442 * xterm.c (x_per_char_metric): Get per character metrics. 10441 * xterm.c (x_per_char_metric): Get per character metrics.
@@ -13869,10 +13868,10 @@
138691998-08-31 Kenichi Handa <handa@etl.go.jp> 138681998-08-31 Kenichi Handa <handa@etl.go.jp>
13870 13869
13871 * charset.c (unibyte_char_to_multibyte): 13870 * charset.c (unibyte_char_to_multibyte):
13872 Vnonacii_translation_table will convert a 7-bit charcater. 13871 Vnonacii_translation_table will convert a 7-bit character.
13873 (multibyte_char_to_unibyte): Handle the case that 13872 (multibyte_char_to_unibyte): Handle the case that
13874 Vnonacii_translation_table converts a multibyte charcater to a 13873 Vnonacii_translation_table converts a multibyte character to a
13875 unibyte charcter of less than 128. 13874 unibyte character of less than 128.
13876 (init_charset_once): Initialize nonascii_insert_offset and 13875 (init_charset_once): Initialize nonascii_insert_offset and
13877 Vnonacii_translation_table. 13876 Vnonacii_translation_table.
13878 13877
diff --git a/src/ChangeLog.trunk b/src/ChangeLog.trunk
index 87b54529f2e..de4ba68bdc0 100644
--- a/src/ChangeLog.trunk
+++ b/src/ChangeLog.trunk
@@ -1,3 +1,827 @@
12010-09-29 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * gnutls.c (emacs_gnutls_handshake): Made into internal function.
4 (Fgnutls_boot): Start the handshake.
5 (emacs_gnutls_read): Perform the handshake from the reader loop.
6 (Fgnutls_boot): Remove some debugging messages.
7 Change indentation throughout to use the Emacs style.
8 (emacs_gnutls_handshake): Cast the fds to something that's
9 possibly the expected length.
10 (emacs_gnutls_write): Return -1 if we try to write before handshake.
11
12 * process.h (Lisp_Process): Add a gnutls_p field to Lisp_Process.
13
14 * process.c (make_process): Set the gnutls_p field to zero by
15 default.
16 (read_process_output): Always call the gnutls_read function if the
17 stream is a gnutls stream.
18 (send_process): Ditto for writes.
19
20 * gnutls.c (emacs_gnutls_write, emacs_gnutls_read): Refuse to read
21 or write anything until the state is GNUTLS_STAGE_READY.
22 (Fgnutls_boot): Mark the stream as being a gnutls stream.
23
242010-09-29 Eli Zaretskii <eliz@gnu.org>
25
26 * xdisp.c (reseat_1): Initialize bidi_it.paragraph_dir to
27 NEUTRAL_DIR.
28 (handle_invisible_prop, iterate_out_of_display_property)
29 (next_element_from_buffer): If bidi_it.first_elt is set, call
30 bidi_paragraph_init with NO_DEFAULT_P argument non-zero.
31 (Bug#7128)
32
33 * print.c (print_object): Fix format string and argument types for
34 printing a Lisp_Misc_Marker.
35
36 * xdisp.c (pos_visible_p, c_string_pos, number_of_chars)
37 (load_overlay_strings, get_overlay_strings_1)
38 (get_overlay_strings, forward_to_next_line_start)
39 (back_to_previous_visible_line_start, reseat, reseat_to_string)
40 (get_next_display_element, next_element_from_string)
41 (next_element_from_c_string, next_element_from_buffer)
42 (move_it_vertically_backward, move_it_by_lines, add_to_log)
43 (message_dolog, message_log_check_duplicate, message2_nolog)
44 (message3, message3_nolog, vmessage, set_message, set_message_1)
45 (hscroll_window_tree, text_outside_line_unchanged_p)
46 (set_cursor_from_row, set_vertical_scroll_bar, redisplay_window)
47 (find_last_unchanged_at_beg_row)
48 (find_first_unchanged_at_end_row, row_containing_pos)
49 (trailing_whitespace_p, display_mode_element, decode_mode_spec)
50 (display_count_lines, x_produce_glyphs, note_mouse_highlight): Use
51 EMACS_INT for buffer and string positions.
52
53 * dispextern.h (struct it) <string_nchars>: Declare EMACS_INT.
54 (row_containing_pos): Adjust prototype.
55
56 * lisp.h (pos_visible_p, message2, message2_nolog, message3)
57 (message2_nolog, set_message): Adjust prototypes.
58
592010-09-28 Stefan Monnier <monnier@iro.umontreal.ca>
60
61 * gnutls.c (Fgnutls_boot): Remove unused vars `data' and `srp_cred'.
62 (Fgnutls_boot): Use SDATA.
63 (Fgnutls_handshake): Remove unused var `max_log_level'.
64
652010-09-27 Michael Albinus <michael.albinus@gmx.de>
66
67 * dbusbind.c (syms_of_dbusbind): Set $DBUS_FATAL_WARNINGS to "0".
68 (Bug#7113)
69
702010-09-27 Jan Djärv <jan.h.d@swipnet.se>
71
72 * xgselect.c (xg_select): Clear file descriptors not set from
73 rfds and wfds.
74
75 * process.c (wait_reading_process_output): Add missing FD_CLR
76 for write_mask (must mirror connect_wait_mask).
77
782010-09-27 Teodor Zlatanov <tzz@lifelogs.com>
79
80 * gnutls.c (gnutls_log_function): Show level and "gnutls.c"
81 prefix.
82 (Fgnutls_boot): Use changed process members. Use log level with a
83 function parameter to set it. Bring back Emacs-level debugging
84 messages at log level 1 and 2.
85
86 * process.c (make_process): Initialize gnutls_log_level.
87
88 * process.h: Add gnutls_log_level and rename x509_cred and
89 anon_cred to have the gnutls_ prefix for consistency.
90
91 * gnutls.h (GNUTLS_LOG): Add convenience macro.
92
932010-09-27 Juanma Barranquero <lekktu@gmail.com>
94
95 * w32.c (g_b_init_get_sid_identifier_authority)
96 (GetSidIdentifierAuthority_Proc, get_sid_identifier_authority):
97 Remove, not used.
98 (globals_of_w32): Don't set g_b_init_get_sid_identifier_authority.
99 (init_winsock): Remove useless assignment.
100 (open_process_token, get_token_information, lookup_account_sid)
101 (get_sid_sub_authority, get_sid_sub_authority_count, get_file_security)
102 (get_security_descriptor_owner, get_security_descriptor_group)
103 (is_valid_sid, equal_sid, get_length_sid, copy_sid)
104 (get_native_system_info, get_system_times, init_user_info, crlf_to_lf)
105 (is_unc_volume, GetCachedVolumeInformation, get_volume_info)
106 (is_fat_volume, open_unc_volume, read_unc_volume, close_unc_volume)
107 (unc_volume_file_attributes, convert_from_time_t)
108 (create_toolhelp32_snapshot, process32_first, process32_next)
109 (open_thread_token, impersonate_self, revert_to_self)
110 (get_process_memory_info, get_process_working_set_size)
111 (global_memory_status, global_memory_status_ex, socket_to_fd)
112 (shutdown_handler): Make static.
113
1142010-09-27 Michael Albinus <michael.albinus@gmx.de>
115
116 * dbusbind.c (dbus_fd_cb, xd_get_dispatch_status)
117 (xd_pending_messages): Functions removed.
118 (xd_read_queued_messages): Add parameters fd, *data, for_read in
119 order to be compatible with add_read_fd. Determine bus from data,
120 and call xd_read_message just for this bus.
121 (xd_add_watch): Use xd_read_queued_messages as callback function.
122 Add data.
123
124 * lisp.h (xd_pending_messages, xd_read_queued_messages): Remove.
125
1262010-09-27 Lars Magne Ingebrigtsen <larsi@gnus.org>
127
128 * gnutls.c (gnutls_log_function): Added more debugging.
129 (emacs_gnutls_read): Don't infloop while reading.
130
1312010-09-27 Kenichi Handa <handa@m17n.org>
132
133 These changes are to remove restriction on the number of glyphs in
134 one composition.
135
136 * dispextern.h (struct glyph): Change the member "slice" to union.
137 Remove u.cmp.from and u.cmp.to. Give more bits to u.cmp.id.
138 (GLYPH_SLICE_EQUAL_P): Adjusted for the above change.
139
140 * dispnew.c (buffer_posn_from_coords): Use glyph->slice.img
141 instead of glyph->slice.
142 (marginal_area_string): Likewise.
143
144 * term.c (encode_terminal_code): Use glyph->slice.cmp instead of
145 glyph->u.cmp.
146 (append_composite_glyph): Likewise.
147
148 * xdisp.c (dump_glyph): Use glyph->slice.cmp instead of
149 glyph->u.cmp.
150 (fill_gstring_glyph_string, x_get_glyph_overhangs)
151 (append_composite_glyph): Likewise.
152 (fill_image_glyph_string): Use glyph->slice.img instead of
153 glyph->slice.
154 (append_glyph, produce_image_glyph, append_stretch_glyph)
155 (note_mouse_highlight): Likewise.
156
1572010-09-26 Jan Djärv <jan.h.d@swipnet.se>
158
159 * process.c (add_keyboard_wait_descriptor)
160 (delete_keyboard_wait_descriptor): Reinstate ifdef subprocesses.
161 (wait_reading_process_output): Don't pass write_mask to select
162 if SELECT_CANT_DO_WRITE_MASK is defined.
163 (SELECT_CANT_DO_WRITE_MASK): Define if SELECT_CANT_DO_WRITE_MASK.
164
165 * process.h (add_read_fd, delete_read_fd, add_write_fd)
166 (delete_write_fd): Declare.
167
168 * process.c (gpm_wait_mask, max_gpm_desc): Remove.
169 (write_mask): New variable.
170 (max_input_desc): Renamed from max_keyboard_desc.
171 (fd_callback_info): New variable.
172 (add_read_fd, delete_read_fd, add_write_fd, delete_write_fd):
173 New functions.
174 (Fmake_network_process): FD_SET write_mask.
175 (deactivate_process): FD_CLR write_mask.
176 (wait_reading_process_output): Connecting renamed to Writeok.
177 check_connect removed. check_write is new. Remove references to gpm.
178 Use Writeok/check_write unconditionally (i.e. no #ifdef
179 NON_BLOCKING_CONNECT) instead of Connecting.
180 Loop over file descriptors and call callbacks in fd_callback_info
181 if file descriptor is ready for I/O.
182 (add_gpm_wait_descriptor): Just call add_keyboard_wait_descriptor.
183 (delete_gpm_wait_descriptor): Just call delete_keyboard_wait_descriptor.
184 (keyboard_bit_set): Use max_input_desc.
185 (add_keyboard_wait_descriptor, delete_keyboard_wait_descriptor):
186 Remove #ifdef subprocesses. Use max_input_desc.
187 (init_process): Initialize write_mask and fd_callback_info.
188
189 * keyboard.c (readable_events, gobble_input): Remove DBUS code.
190
191 * dbusbind.c: Include process.h.
192 (dbus_fd_cb, xd_find_watch_fd, xd_toggle_watch)
193 (xd_read_message_1): New functions.
194 (xd_add_watch, xd_remove_watch): Call xd_find_watch_fd.
195 Handle watch for both read and write.
196 (Fdbus_init_bus): Also register xd_toggle_watch.
197 (Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
198 (Fdbus_method_error_internal, Fdbus_send_signal): Remove call
199 to dbus_connection_flush.
200 (xd_read_message): Move most of the code to xd_read_message_1.
201 Call xd_read_message_1 until status is COMPLETE.
202
2032010-09-26 Dan Nicolaescu <dann@ics.uci.edu>
204
205 * term.c: Do not include sys/ioctl.h, not needed.
206 (init_tty): Reorder code to reduce the number of #ifdefs.
207 No code changes.
208
2092010-09-26 Teodor Zlatanov <tzz@lifelogs.com>
210
211 * process.h: Set up GnuTLS support.
212
213 * process.c (make_process, Fstart_process)
214 (read_process_output, send_process): Set up GnuTLS support for
215 process input/output file descriptors.
216
217 * gnutls.h: The GnuTLS glue for Emacs, macros and enums.
218
219 * gnutls.c: The source code for GnuTLS support in Emacs.
220
221 * emacs.c: Set up GnuTLS support and call syms_of_gnutls.
222
223 * config.in: Set up GnuTLS support.
224
225 * Makefile.in (LIBGNUTLS_LIBS, LIBGNUTLS_CFLAGS, ALL_CFLAGS)
226 (obj, LIBES): Set up GnuTLS support.
227
2282010-09-26 Juanma Barranquero <lekktu@gmail.com>
229
230 * w32.c (get_emacs_configuration_options): Fix previous change.
231
2322010-09-25 Chong Yidong <cyd@stupidchicken.com>
233
234 * insdel.c (prepare_to_modify_buffer): Ensure the mark marker is
235 alive before using it (Bug#6977).
236
2372010-09-25 Lars Magne Ingebrigtsen <larsi@gnus.org>
238
239 * xdisp.c (face_before_or_after_it_pos): EMACS_INT/int fixup.
240
241 * dispextern.h: EMACS_INT/int fixup.
242
243 * xdisp.c (string_pos_nchars_ahead, init_iterator): EMACS_INT/int
244 fixup.
245
246 * xrdb.c (magic_file_p): EMACS_INT/int fixup.
247
2482010-09-25 Eli Zaretskii <eliz@gnu.org>
249
250 * window.c (Fpos_visible_in_window_p, Fdelete_other_windows)
251 (Fselect_window, window_scroll_pixel_based)
252 (window_scroll_line_based, Frecenter, Fset_window_configuration):
253 Use EMACS_INT for buffer positions.
254
255 * textprop.c (validate_interval_range, interval_of)
256 (property_change_between_p, Fadd_text_properties)
257 (set_text_properties_1, Fremove_text_properties)
258 (Fremove_list_of_text_properties, Ftext_property_any)
259 (Ftext_property_not_all, copy_text_properties)
260 (text_property_list, extend_property_ranges)
261 (verify_interval_modification): Use EMACS_INT for buffer
262 positions.
263
264 * term.c (fast_find_position, term_mouse_highlight): Use EMACS_INT
265 for buffer positions.
266
267 * process.c (read_process_output, send_process)
268 (Fprocess_send_region, status_notify): Use EMACS_INT for buffer
269 and string positions and size.
270
271 * print.c (print_object, print_string, strout): Use EMACS_INT for
272 string indices.
273
274 * minibuf.c (string_to_object): Use EMACS_INT for string position
275 and size.
276
277 * marker.c (verify_bytepos): Use EMACS_INT for buffer positions.
278
279 * lread.c <read_from_string_index, read_from_string_index_byte>
280 <read_from_string_limit, readchar_count>: Define EMACS_INT.
281 (readchar, unreadchar, read_internal_start): Use EMACS_INT for
282 buffer positions and string length.
283
284 * keyboard.c <last_point_position, last_non_minibuf_size>: Declare
285 EMACS_INT.
286 (echo_truncate, adjust_point_for_property, read_char)
287 (gen_help_event, make_lispy_event, modify_event_symbol)
288 (Fexecute_extended_command, stuff_buffered_input): Use EMACS_INT
289 for buffer positions and string length.
290
291 * keyboard.h (gen_help_event): Adjust prototype.
292
293 * termhooks.h <struct input_event>: Make `code' member EMACS_INT.
294
295 * commands.h <last_point_position>: Declare EMACS_INT.
296
297 * xdisp.c <help_echo_pos>: Define as EMACS_INT.
298 (truncate_echo_area): Accept EMACS_INT argument.
299
300 * dispextern.h <help_echo_pos>: Declare EMACS_INT.
301
302 * lisp.h (truncate_echo_area): Adjust prototype.
303
304 * composite.c (composition_adjust_point): Return EMACS_INT.
305
306 * composite.h (composition_adjust_point): Adjust prototype.
307
3082010-09-25 Juanma Barranquero <lekktu@gmail.com>
309
310 * process.c (Fmake_network_process): When arg :host is 'local,
311 use address 127.0.0.1, not name "localhost". (Bug#6781)
312
3132010-09-24 Eli Zaretskii <eliz@gnu.org>
314
315 * indent.c (Fcurrent_indentation, indented_beyond_p)
316 (compute_motion): Use EMACS_INT for buffer position variables.
317
318 * lisp.h (indented_beyond_p): Adjust prototype.
319
320 * buffer.c (overlay_strings): Return EMACS_INT.
321
322 * buffer.h (overlay_strings): Adjust prototype.
323
324 * region-cache.c (pp_cache): Adjust format to arguments.
325
326 * eval.c <specpdl_size, lisp_eval_depth>: Declare EMACS_INT.
327 (call_debugger): Use EMACS_INT for specpdl_size related variables.
328 (verror): Use EMACS_INT for size of allocated buffer.
329
330 * keyboard.c (make_lispy_position): Use EMACS_INT for buffer
331 positions.
332
333 * xdisp.c (redisplay_internal, try_window_id)
334 (set_cursor_from_row, find_first_unchanged_at_end_row): Use
335 EMACS_INT for buffer positions.
336
337 * dispextern.h (set_cursor_from_row): Adjust prototype.
338
339 * dispnew.c (increment_matrix_positions)
340 (increment_row_positions, copy_glyph_row_contents)
341 (mode_line_string, marginal_area_string): Use EMACS_INT for buffer
342 positions.
343
344 * dispextern.h (mode_line_string, marginal_area_string)
345 (increment_matrix_positions, increment_row_positions): Adjust
346 prototypes.
347
348 * data.c (Faref, Faset): Use EMACS_INT for string length and
349 positions.
350
351 * cmds.c (internal_self_insert): Use EMACS_INT for the count of
352 characters to insert.
353
354 * ccl.c (Fccl_execute_on_string): Use EMACS_INT for string
355 position and size.
356
357 * syntax.c (scan_words, update_syntax_table)
358 (prev_char_comend_first, back_comment, skip_chars)
359 (skip_syntaxes, Fforward_comment, Fbackward_prefix_chars): Use
360 EMACS_INT for buffer and string positions.
361
362 * syntax.h (scan_words, update_syntax_table): Adjust prototypes.
363
364 * casefiddle.c (operate_on_word): Use EMACS_INT for buffer
365 positions.
366
3672010-09-24 Lars Magne Ingebrigtsen <larsi@gnus.org>
368
369 * scroll.c (calculate_scrolling, line_ins_del)
370 (calculate_direct_scrolling, scroll_cost): Fix EMACS_INT/int
371 conversion.
372
373 * region-cache.c (move_cache_gap, set_cache_region, pp_cache)
374 (region_cache_backward, region_cache_forward)
375 (revalidate_region_cache, set_cache_region): FIX EMACS_INT/int
376 conversion.
377
378 * xdisp.c (message_dolog): Fix EMACS_INT/int conversion.
379
380 * eval.c (verror): Fix EMACS_INT/int conversion.
381
382 * print.c (PRINTDECLARE, PRINTPREPARE, strout, print_string)
383 (print_preprocess, print_check_string_charset_prop)
384 (print_object): Fix EMACS_INT/int conversion.
385
386 * xdisp.c (message_dolog): Fix EMACS_INT/int conversion.
387
3882010-09-24 Eli Zaretskii <eliz@gnu.org>
389
390 * callproc.c (Fcall_process): Use EMACS_INT for count of
391 characters read from the subprocess.
392
393 * bidi.c (struct bidi_paragraph_info): Use EMACS_INT for buffer
394 positions.
395 (bidi_cache_search, bidi_cache_find): Use EMACS_INT for buffer
396 positions.
397
398 * buffer.c (struct sortvec): Use EMACS_INT for buffer positions.
399 (struct sortstrlist, overlay_str_len): Use EMACS_INT for string
400 length.
401 (advance_to_char_boundary, Fset_buffer_multibyte)
402 (overlays_at, overlays_in, mouse_face_overlay_overlaps)
403 (overlay_touches_p, record_overlay_string, overlay_strings)
404 (recenter_overlay_lists, fix_start_end_in_overlays)
405 (modify_overlay, Fmove_overlay, report_overlay_modification)
406 (evaporate_overlays): Use EMACS_INT for buffer positions.
407
408 * lisp.h (fix_start_end_in_overlays, overlay_touches_p): Adjust
409 prototypes.
410
411 * dispextern.h (struct bidi_saved_info): Use EMACS_INT for buffer
412 positions.
413
414 * fns.c (Fcompare_strings, Fstring_lessp, concat)
415 (string_make_unibyte, Fstring_as_unibyte, Fsubstring)
416 (Fsubstring_no_properties, substring_both, Ffillarray)
417 (Fclear_string, mapcar1, Fmapconcat, Fmapcar, Fmapc)
418 (Fbase64_encode_region, Fbase64_encode_string, base64_encode_1)
419 (Fbase64_decode_region, Fbase64_decode_string, base64_decode_1)
420 (Fmd5): Use EMACS_INT for buffer and string positions and length
421 variables and arguments.
422
423 * lisp.h (substring_both): Adjust prototype.
424
4252010-09-24 Juanma Barranquero <lekktu@gmail.com>
426
427 Remove W32 API function pointer unused since 2005-02-15 (revno 2005-02-15T23:19:26Z!jasonr@gnu.org).
428 * w32fns.c (clipboard_sequence_fn): Don't declare.
429 (globals_of_w32fns): Don't initialize it.
430
4312010-09-23 Stefan Monnier <monnier@iro.umontreal.ca>
432
433 * syntax.c (back_comment): Detect the case where a 1-char comment
434 starter is also the 2nd char of a 2-char comment ender.
435
4362010-09-23 Jan Djärv <jan.h.d@swipnet.se>
437
438 * gtkutil.c (xg_tool_bar_menu_proxy): Set gtk-menu-items to TRUE.
439
4402010-09-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
441
442 * eval.c (verror): EMACS_INT/int cleanup.
443
444 * lisp.h (SPECPDL_INDEX): Cast to int, since we're not going to
445 unwind_protect more than 2GB worth of functions.
446
447 * editfns.c (Finsert_char): EMACS_INT/int cleanup.
448
449 * lisp.h: Have oblookup take EMACS_INT to allow interning big
450 string and avoid compiler warnings.
451 (USE_SAFE_ALLOCA): Cast to int to avoid compilation warnings in
452 all users.
453
454 * lread.c (oblookup): EMACS_INT/int cleanup.
455
456 * cmds.c (Fforward_line, Fdelete_char): EMACS_INT/int cleanup.
457
4582010-09-23 Eli Zaretskii <eliz@gnu.org>
459
460 * editfns.c (clip_to_bounds): Return an EMACS_INT value.
461
462 * lisp.h (clip_to_bounds): Adjust prototype.
463
464 * intervals.c (adjust_for_invis_intang): Return EMACS_INT value.
465
4662010-09-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
467
468 * lisp.h: doprnt.c EMACS_INT/int cleanup.
469
470 * doprnt.c (doprnt): EMACS_INT/int cleanup.
471
472 * doc.c (Fsnarf_documentation, get_doc_string): EMACS_INT/int
473 cleanup.
474
475 * lisp.h: Change the definition of all marker.c functions that
476 take and return buffer stuff to be EMACS_INT instead of int.
477
478 * marker.c (buf_charpos_to_bytepos, CONSIDER, set_marker_both)
479 (buf_charpos_to_bytepos, bytepos_to_charpos)
480 (buf_bytepos_to_charpos, Fbuffer_has_markers_at)
481 (set_marker_restricted, set_marker_both): Convert int to EMACS_INT
482 for all buffer positions.
483
4842010-09-23 Chong Yidong <cyd@stupidchicken.com>
485
486 * intervals.c (traverse_intervals, rotate_right, rotate_left)
487 (split_interval_right, find_interval, next_interval)
488 (delete_node, delete_interval, interval_deletion_adjustment)
489 (adjust_intervals_for_deletion, merge_interval_right)
490 (merge_interval_left, graft_intervals_into_buffer)
491 (copy_intervals): Convert EMACS_UINTs to EMACS_INT.
492
493 * intervals.h (traverse_intervals): Update prototype.
494
4952010-09-23 Eli Zaretskii <eliz@gnu.org>
496
497 * indent.c (compute_motion): Use EMACS_INT for arguments to
498 region_cache_forward.
499
500 * region-cache.c (struct boundary, struct region_cache): Use
501 EMACS_INT for positions.
502 (find_cache_boundary, move_cache_gap, insert_cache_boundary)
503 (delete_cache_boundaries, set_cache_region)
504 (invalidate_region_cache, know_region_cache)
505 (region_cache_forward, region_cache_backward, pp_cache): Use
506 EMACS_INT for buffer positions.
507
508 * region-cache.h (know_region_cache, invalidate_region_cache)
509 (region_cache_forward, region_cache_backward): Adjust prototypes.
510
511 * search.c (string_match_1, fast_c_string_match_ignore_case)
512 (looking_at_1, scan_buffer, scan_newline)
513 (find_next_newline_no_quit, find_before_next_newline)
514 (search_command, trivial_regexp_p, search_buffer, simple_search)
515 (boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer
516 and string positions and length.
517
518 * lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit)
519 (find_before_next_newline): Adjust prototypes.
520
521 * editfns.c (transpose_markers, update_buffer_properties)
522 (buildmark, clip_to_bounds, Fgoto_char, overlays_around)
523 (get_pos_property, Fconstrain_to_field)
524 (Fline_beginning_position, Fline_end_position, Fprevious_char)
525 (Fchar_after, Fchar_before, Finsert_char)
526 (Finsert_buffer_substring, Fcompare_buffer_substrings)
527 (Fsubst_char_in_region, Fformat, Ftranspose_regions): Use
528 EMACS_INT for buffer and string position variables.
529 (Finsert_char): Protect against too large insertions.
530
531 * lisp.h (clip_to_bounds): Adjust prototype.
532
533 * intervals.c (traverse_intervals, rotate_right, rotate_left)
534 (balance_an_interval, split_interval_right, split_interval_left)
535 (find_interval, next_interval, update_interval)
536 (adjust_intervals_for_insertion, delete_node, delete_interval)
537 (interval_deletion_adjustment, adjust_intervals_for_deletion)
538 (offset_intervals, merge_interval_right, merge_interval_left)
539 (graft_intervals_into_buffer, adjust_for_invis_intang)
540 (move_if_not_intangible, get_local_map, copy_intervals)
541 (copy_intervals_to_string, compare_string_intervals)
542 (set_intervals_multibyte_1): Use EMACS_INT for buffer positions
543 and for interval tree size.
544
545 * intervals.h (traverse_intervals, split_interval_right)
546 (split_interval_left, find_interval, offset_intervals)
547 (graft_intervals_into_buffer, copy_intervals)
548 (copy_intervals_to_string, move_if_not_intangible, get_local_map)
549 (update_interval): Adjust prototypes.
550
551 * xdisp.c (check_point_in_composition, reconsider_clip_changes):
552 Use EMACS_INT for buffer position variables and arguments.
553
554 * composite.c (get_composition_id, find_composition)
555 (run_composition_function, compose_text)
556 (composition_gstring_width, autocmp_chars)
557 (composition_update_it, Ffind_composition_internal): Use EMACS_INT
558 for buffer positions and string length variables and arguments.
559
560 * composite.h (get_composition_id, find_composition, compose_text)
561 (composition_gstring_width): Adjust prototypes.
562
563 * editfns.c (Fformat): Use EMACS_INT for string size variables.
564
565 * xdisp.c (store_mode_line_noprop, display_mode_element): Use
566 EMACS_INT for string positions.
567
568 * intervals.c (get_property_and_range): Use EMACS_INT for buffer
569 position arguments.
570
571 * intervals.h (get_property_and_range): Adjust prototype.
572
573 * character.c (parse_str_as_multibyte, str_as_multibyte)
574 (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte)
575 (string_count_byte8, string_escape_byte8, c_string_width)
576 (strwidth, lisp_string_width, multibyte_chars_in_text): Use
577 EMACS_INT for string length variables and arguments.
578
579 * character.h (parse_str_as_multibyte, str_as_multibyte)
580 (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte)
581 (c_string_width, strwidth, lisp_string_width): Adjust
582 prototypes.
583
584 * font.c (font_intern_prop): Use EMACS_INT for string length
585 variables.
586
587 * font.c (font_intern_prop): Use EMACS_INT for string length
588 variables.
589
590 * fns.c (Fstring_as_multibyte): Use EMACS_INT for string length
591 variables.
592
593 * alloc.c <total_string_size>: Declare as EMACS_INT, not int.
594 (Fmake_string): Protect against too large strings.
595 (live_string_p, live_cons_p, live_symbol_p, live_float_p)
596 (live_misc_p): Use ptrdiff_t instead of int for pointer
597 differences.
598 (string_bytes, check_sblock, check_string_free_list)
599 (allocate_string_data, compact_small_strings, Fmake_string)
600 (Fmake_bool_vector, make_string, make_unibyte_string)
601 (make_multibyte_string, make_string_from_bytes)
602 (make_specified_string_string, Fmake_list, Fmake_vector): Use
603 EMACS_INT for string length variables and arguments.
604 (find_string_data_in_pure, make_pure_string, make_pure_c_string)
605 (Fpurecopy): Use EMACS_INT for string size.
606 (mark_vectorlike, mark_char_table, mark_object): Use EMACS_UINT
607 for vector size.
608
609 * lisp.h (make_string, make_unibyte_string, make_multibyte_string)
610 (make_string_from_bytes, make_specified_string_string)
611 (make_pure_string, string_bytes, check_point_in_composition):
612 Adjust prototypes.
613
6142010-09-22 Eli Zaretskii <eliz@gnu.org>
615
616 * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal)
617 (check_translation): Use EMACS_INT for buffer positions and
618 length.
619
620 * undo.c (record_marker_adjustment, record_delete)
621 (record_change, record_point, record_insert)
622 (record_property_change, Fprimitive_undo): Use EMACS_INT for
623 buffer positions.
624
625 * lisp.h (record_marker_adjustment, record_delete)
626 (record_change, record_point, record_insert)
627 (record_property_change, Fprimitive_undo): Adjust prototypes.
628
6292010-09-22 Juanma Barranquero <lekktu@gmail.com>
630 Eli Zaretskii <eliz@gnu.org>
631
632 * w32.c (get_emacs_configuration_options): Fix buffer overrun.
633
6342010-09-22 Eli Zaretskii <eliz@gnu.org>
635
636 * minibuf.c (Fminibuffer_contents)
637 (Fminibuffer_contents_no_properties)
638 (Fminibuffer_completion_contents): Use EMACS_INT for minibuffer
639 positions.
640
641 * keyboard.c (command_loop_1): Use EMACS_INT to compare point with
642 mark.
643
644 * alloc.c (make_uninit_string, make_uninit_multibyte_string)
645 (allocate_string_data): Accept EMACS_INT for string length.
646
647 * editfns.c (Ffield_string, Ffield_string_no_properties)
648 (make_buffer_string, make_buffer_string_both, Fbuffer_substring)
649 (Fbuffer_substring_no_properties, find_field, Fdelete_field)
650 (Ffield_string, Ffield_string_no_properties, Ffield_beginning)
651 (Ffield_end): Use EMACS_INT for buffer positions.
652
653 * insdel.c (prepare_to_modify_buffer): Use EMACS_INT to compare
654 point with mark.
655
656 * lisp.h (allocate_string_data, make_uninit_string)
657 (make_uninit_multibyte_string, make_buffer_string)
658 (make_buffer_string_both): Adjust prototypes.
659
6602010-09-22 Chong Yidong <cyd@stupidchicken.com>
661
662 * xml.c: Switch to GNU indentation.
663 (make_dom): Change parse tree format to match xml.el.
664 (Fxml_parse_html_string_internal): Rename from html-parse-string.
665 (Fxml_parse_string_internal): Rename from xml-parse-string.
666
6672010-09-22 Kenichi Handa <handa@m17n.org>
668
669 * xdisp.c (compute_stop_pos): Call composition_compute_stop_pos
670 only if we are not at a composition.
671 (set_iterator_to_next): Give it->end_charpos to
672 composition_compute_stop_pos.
673 (set_iterator_to_next, next_element_from_buffer): Likewise.
674
675 * dispnew.c (buffer_posn_from_coords): Fix position when the
676 current display element is a grapheme cluster in bidi-reordered
677 region.
678
6792010-09-21 Ari Roponen <ari.roponen@gmail.com> (tiny change)
680
681 * doc.c (Fsnarf_documentation): Use memmove instead of memcpy as
682 the regions may overlap.
683
6842010-09-21 Juanma Barranquero <lekktu@gmail.com>
685
686 * makefile.w32-in ($(BLD)/sysdep.$(O)): Update dependencies.
687
6882010-09-21 Dan Nicolaescu <dann@ics.uci.edu>
689
690 * emacs.c: Do not include sys/ioctl.h, not needed.
691
692 * doprnt.c: Do not include stdlib.h, config.h does it.
693 Move #include before macro definition.
694
6952010-09-20 Dan Nicolaescu <dann@ics.uci.edu>
696
697 * Makefile.in (temacs): Link using $(CC) not $(LD).
698 (LD_FIRSTFLAG): Define using autoconf.
699 (LD): Remove.
700
701 Remove HAVE_TERMIOS definitions.
702 * s/usg5-4-common.h (HAVE_TERMIOS):
703 * s/template.h (HAVE_TERMIOS):
704 * s/gnu-linux.h (HAVE_TERMIOS):
705 * s/darwin.h (HAVE_TERMIOS):
706 * s/cygwin.h (HAVE_TERMIOS):
707 * s/bsd-common.h (HAVE_TERMIOS):
708 * s/aix4-2.h (HAVE_TERMIOS):
709 * s/hpux10-20.h (HAVE_TERMIOS): Do not define, it is assumed
710 defined on all non-MS platforms.
711 (HAVE_PSTAT_GETDYNAMIC): Do not define, autoconf does it.
712
713 * xterm.c (xt_action_hook): Use const.
714
7152010-09-20 Juanma Barranquero <lekktu@gmail.com>
716
717 Don't make W32 code conditional on HAVE_SOCKETS, it's always defined.
718 * w32.c: Remove top-level uses of #ifdef HAVE_SOCKETS.
719 (gethostname) [!HAVE_SOCKETS]: Remove.
720 (SOCK_REPLACE_HANDLE): Remove macro.
721 (socket_to_fd, sys_close, _sys_read_ahead, sys_read, sys_write)
722 (term_ntproc, init_ntproc): Don't conditionalize on HAVE_SOCKETS.
723 * w32proc.c: Remove top-level uses of #ifdef HAVE_SOCKETS.
724 (syms_of_ntproc): Don't conditionalize on HAVE_SOCKETS.
725
7262010-09-18 Eli Zaretskii <eliz@gnu.org>
727
728 * deps.mk (xml.o): Add dependencies.
729
730 * xdisp.c (Fcurrent_bidi_paragraph_direction):
731 Call bidi_paragraph_init with NO_DEFAULT_P non-zero. (Bug#7038)
732
733 * bidi.c (bidi_paragraph_init): Accept an additional argument
734 NO_DEFAULT_P; all callers changed. If NO_DEFAULT_P is non-zero,
735 search back until a paragraph with a strong directional character
736 is found, and use that to determine paragraph's base direction.
737
738 * dispextern.h (bidi_paragraph_init): Update prototype.
739
7402010-09-17 Eli Zaretskii <eliz@gnu.org>
741
742 * w32.c (_PROCESS_MEMORY_COUNTERS_EX): Don't define with versions
743 of w32api >= 3.15. (Bug#6989)
744
7452010-09-17 Lars Magne Ingebrigtsen <larsi@gnus.org>
746
747 * process.c (wait_reading_process_output): Don't message about
748 accept-process-output unless the time limit really is zero.
749
7502010-09-17 Stefan Monnier <monnier@iro.umontreal.ca>
751
752 * frame.c (Ftool_bar_pixel_width): YAILOM (Yet another
753 int/Lisp_Object mixup).
754
7552010-09-17 Jan Djärv <jan.h.d@swipnet.se>
756
757 * keyboard.c (parse_tool_bar_item): For QClabel, set TOOL_BAR_ITEM_LABEL
758 not HELP.
759
7602010-09-17 Stephen Berman <stephen.berman@gmx.net>
761
762 * frame.c (Ftool_bar_pixel_width): New function to expose tool
763 bar's pixel width to Lisp (Bug#7048).
764
7652010-09-14 Juanma Barranquero <lekktu@gmail.com>
766
767 * cmds.c (syms_of_cmds) <post-self-insert-hook>: Fix typos in docstring.
768
7692010-09-17 Jan Djärv <jan.h.d@swipnet.se>
770
771 * gtkutil.c (xg_pack_tool_bar): Call gtk_handle_box_set_handle_position
772 with argument top/left if tool bar is vertical/horizontal (Bug#7051).
773
7742010-09-17 Kenichi Handa <handa@m17n.org>
775
776 * ftfont.c (ftfont_check_otf): Fix previous change.
777
7782010-09-14 Kenichi Handa <handa@m17n.org>
779
780 * ftfont.c (ftfont_check_otf): Fix the case of checking just
781 existence of GSUB or GPOS.
782
7832010-09-14 Juanma Barranquero <lekktu@gmail.com>
784
785 * cmds.c (syms_of_cmds) <post-self-insert-hook>: Fix typos in docstring.
786
7872010-09-14 Lars Magne Ingebrigtsen <larsi@gnus.org>
788
789 * xml.c (parse_buffer): Renamed to parse_string(), since that's
790 what it does.
791 (parse_string): Return nil when the document can't be parsed.
792
7932010-09-14 Jan Djärv <jan.h.d@swipnet.se>
794
795 * xterm.c (get_current_vm_state): New function.
796 (do_ewmh_fullscreen): Call get_current_vm_state and compare with
797 want_fullscreen so set_wm_state calls are few (Bug#7013).
798 (x_handle_net_wm_state): Move code to get_current_vm_state and
799 call that function.
800
8012010-09-14 Courtney Bane <emacs-bugs-7626@cbane.org> (tiny change)
802
803 * term.c (tty_set_terminal_modes): Don't initialize twice (bug#7002).
804
8052010-09-14 Kenichi Handa <handa@m17n.org>
806
807 * coding.c (encode_coding_iso_2022): Don't optimize for ASCII if
808 we may use designation or locking-shift.
809
8102010-09-14 Kenichi Handa <handa@m17n.org>
811
812 * coding.c (detect_coding_emacs_mule): Fix checking of multibyte
813 sequence when the source is multibyte.
814
8152010-09-14 Andreas Schwab <schwab@linux-m68k.org>
816
817 * xml.c (Fxml_parse_string, Fxml_parse_string): Revert last change.
818 Don't make first argument optional. Doc fix.
819
8202010-09-14 Leo <sdl.web@gmail.com> (tiny change)
821
822 * xml.c (Fxml_parse_string, Fhtml_parse_string): Fix up the
823 parameters for the doc string.
824
12010-09-12 Lars Magne Ingebrigtsen <larsi@gnus.org> 8252010-09-12 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 826
3 * xml.c (Fhtml_parse_string, Fxml_parse_string): Mention BASE-URL. 827 * xml.c (Fhtml_parse_string, Fxml_parse_string): Mention BASE-URL.
@@ -101,9 +925,9 @@
101 (produce_stretch_glyph): Set it2.char_to_display too before 925 (produce_stretch_glyph): Set it2.char_to_display too before
102 calling x_produce_glyphs. 926 calling x_produce_glyphs.
103 (x_produce_glyphs): Simplify by using the same code for ASCII and 927 (x_produce_glyphs): Simplify by using the same code for ASCII and
104 non-ASCII characters. Don't set it->char_to_display here. Don't 928 non-ASCII characters. Don't set it->char_to_display here.
105 handle unibyte-display-via-language-environment here. For a 929 Don't handle unibyte-display-via-language-environment here. For a
106 charater of no glyph, use font->space_width instead of FONT_WIDTH. 930 character of no glyph, use font->space_width instead of FONT_WIDTH.
107 931
1082010-08-31 Stefan Monnier <monnier@iro.umontreal.ca> 9322010-08-31 Stefan Monnier <monnier@iro.umontreal.ca>
109 933
@@ -344,7 +1168,7 @@
344 1168
3452010-08-18 Jan Djärv <jan.h.d@swipnet.se> 11692010-08-18 Jan Djärv <jan.h.d@swipnet.se>
346 1170
347 * gtkutil.c (update_frame_tool_bar): Literal stings are const char*. 1171 * gtkutil.c (update_frame_tool_bar): Literal strings are const char*.
348 1172
3492010-08-18 David De La Harpe Golden <david@harpegolden.net> 11732010-08-18 David De La Harpe Golden <david@harpegolden.net>
350 1174
@@ -534,7 +1358,7 @@
534 * xterm.c (emacs_class): New char[] for EMACS_CLASS. 1358 * xterm.c (emacs_class): New char[] for EMACS_CLASS.
535 (xim_open_dpy, xim_initialize, xim_close_dpy): Use emacs_class. 1359 (xim_open_dpy, xim_initialize, xim_close_dpy): Use emacs_class.
536 (x_term_init): Use char[] display_opt and name_opt instead of 1360 (x_term_init): Use char[] display_opt and name_opt instead of
537 string literal. file is const char*. 1361 string literal. file is const char*.
538 1362
539 * xsmfns.c (NOSPLASH_OPT): Change to char[]. 1363 * xsmfns.c (NOSPLASH_OPT): Change to char[].
540 (smc_save_yourself_CB): Do xstrdup on all ->type and ->name for 1364 (smc_save_yourself_CB): Do xstrdup on all ->type and ->name for
@@ -546,7 +1370,7 @@
546 non-const char. 1370 non-const char.
547 1371
548 * xmenu.c (Fx_popup_dialog): error_name is const char*. 1372 * xmenu.c (Fx_popup_dialog): error_name is const char*.
549 (xmenu_show): error parameter is const char **. pane_string is const 1373 (xmenu_show): error parameter is const char **. pane_string is const
550 char *. 1374 char *.
551 (button_names): Is const char *. 1375 (button_names): Is const char *.
552 (xdialog_show): error_name and pane_string is const. 1376 (xdialog_show): error_name and pane_string is const.
@@ -2303,7 +3127,7 @@
2303 (smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings 3127 (smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings
2304 passed to strlen/strcpy/strcat. 3128 passed to strlen/strcpy/strcat.
2305 (create_client_leader_window): Surround with #ifndef USE_GTK. Cast 3129 (create_client_leader_window): Surround with #ifndef USE_GTK. Cast
2306 7:th arg to XChangeProperty to (unsigned char *) 3130 7:th arg to XChangeProperty to (unsigned char *).
2307 3131
2308 * xsettings.c (something_changedCB, parse_settings) 3132 * xsettings.c (something_changedCB, parse_settings)
2309 (apply_xft_settings): Reformat prototype. 3133 (apply_xft_settings): Reformat prototype.
@@ -18625,7 +19449,7 @@
18625 (Ffont_shape_text): New function. 19449 (Ffont_shape_text): New function.
18626 (Fopen_font): If the font size is not given, use 12-pixel. 19450 (Fopen_font): If the font size is not given, use 12-pixel.
18627 (Ffont_at): New arg STRING. 19451 (Ffont_at): New arg STRING.
18628 (syms_of_font): Initalize font_charset_alist. 19452 (syms_of_font): Initialize font_charset_alist.
18629 Declare Ffont_shape_text as a Lisp function. Call syms_of_XXfont 19453 Declare Ffont_shape_text as a Lisp function. Call syms_of_XXfont
18630 conditionally. 19454 conditionally.
18631 19455
@@ -19622,7 +20446,7 @@
19622 20446
19623 * font.c (font_unparse_fcname): Fix typo (swidth->width). 20447 * font.c (font_unparse_fcname): Fix typo (swidth->width).
19624 (font_list_entities): Check driver_list->on. 20448 (font_list_entities): Check driver_list->on.
19625 (register_font_driver): Initalize `on' member to 0. 20449 (register_font_driver): Initialize `on' member to 0.
19626 (font_update_drivers): New function. 20450 (font_update_drivers): New function.
19627 (Fclear_font_cache): Check driver_list->on. 20451 (Fclear_font_cache): Check driver_list->on.
19628 20452
@@ -20265,7 +21089,7 @@
20265 21089
20266 * search.c (search_buffer): Give up BM search on case-fold-search 21090 * search.c (search_buffer): Give up BM search on case-fold-search
20267 if one of a target character has a case-equivalence of different 21091 if one of a target character has a case-equivalence of different
20268 byte length even if that target charcter is an ASCII. 21092 byte length even if that target character is an ASCII.
20269 (simple_search): Fix calculation of byte length of matched text. 21093 (simple_search): Fix calculation of byte length of matched text.
20270 (boyer_moore): Fix handling of case-equivalent multibyte characters. 21094 (boyer_moore): Fix handling of case-equivalent multibyte characters.
20271 21095
diff --git a/src/Makefile.in b/src/Makefile.in
index d91b95d86e3..00706460d25 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -35,6 +35,7 @@ CC = @CC@
35CFLAGS = @CFLAGS@ 35CFLAGS = @CFLAGS@
36CPPFLAGS = @CPPFLAGS@ 36CPPFLAGS = @CPPFLAGS@
37LDFLAGS = @LDFLAGS@ 37LDFLAGS = @LDFLAGS@
38LD_FIRSTFLAG=@LD_FIRSTFLAG@
38EXEEXT = @EXEEXT@ 39EXEEXT = @EXEEXT@
39version = @version@ 40version = @version@
40# Substitute an assignment for the MAKE variable, because 41# Substitute an assignment for the MAKE variable, because
@@ -124,8 +125,6 @@ LIBS_SYSTEM=@LIBS_SYSTEM@
124## Where to find libgcc.a, if using gcc and necessary. 125## Where to find libgcc.a, if using gcc and necessary.
125LIB_GCC=@LIB_GCC@ 126LIB_GCC=@LIB_GCC@
126 127
127LD=@LINKER@
128
129## May use $CRT_DIR. 128## May use $CRT_DIR.
130LIB_STANDARD=@LIB_STANDARD@ 129LIB_STANDARD=@LIB_STANDARD@
131 130
@@ -287,6 +286,9 @@ LIBRESOLV = @LIBRESOLV@
287 286
288LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ 287LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
289 288
289LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
290LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
291
290INTERVALS_H = dispextern.h intervals.h composite.h 292INTERVALS_H = dispextern.h intervals.h composite.h
291 293
292GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ 294GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
@@ -326,6 +328,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} \
326 ${LIBXML2_CFLAGS} ${DBUS_CFLAGS} \ 328 ${LIBXML2_CFLAGS} ${DBUS_CFLAGS} \
327 ${GCONF_CFLAGS} ${FREETYPE_CFLAGS} ${FONTCONFIG_CFLAGS} \ 329 ${GCONF_CFLAGS} ${FREETYPE_CFLAGS} ${FONTCONFIG_CFLAGS} \
328 ${LIBOTF_CFLAGS} ${M17N_FLT_CFLAGS} ${DEPFLAGS} ${PROFILING_CFLAGS} \ 330 ${LIBOTF_CFLAGS} ${M17N_FLT_CFLAGS} ${DEPFLAGS} ${PROFILING_CFLAGS} \
331 $(LIBGNUTLS_CFLAGS) \
329 ${C_WARNINGS_SWITCH} ${CFLAGS} 332 ${C_WARNINGS_SWITCH} ${CFLAGS}
330ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) 333ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
331 334
@@ -350,7 +353,7 @@ obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
350 alloc.o data.o doc.o editfns.o callint.o \ 353 alloc.o data.o doc.o editfns.o callint.o \
351 eval.o floatfns.o fns.o font.o print.o lread.o \ 354 eval.o floatfns.o fns.o font.o print.o lread.o \
352 syntax.o $(UNEXEC_OBJ) bytecode.o \ 355 syntax.o $(UNEXEC_OBJ) bytecode.o \
353 process.o callproc.o \ 356 process.o gnutls.o callproc.o \
354 region-cache.o sound.o atimer.o \ 357 region-cache.o sound.o atimer.o \
355 doprnt.o strftime.o intervals.o textprop.o composite.o md5.o xml.o \ 358 doprnt.o strftime.o intervals.o textprop.o composite.o md5.o xml.o \
356 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) 359 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ)
@@ -602,6 +605,7 @@ LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
602 ${LIBXML2_LIBS} $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 605 ${LIBXML2_LIBS} $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
603 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \ 606 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \
604 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 607 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
608 $(LIBGNUTLS_LIBS) \
605 $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) 609 $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
606 610
607all: emacs${EXEEXT} $(OTHER_FILES) 611all: emacs${EXEEXT} $(OTHER_FILES)
@@ -646,7 +650,7 @@ buildobj.h: Makefile
646 650
647 651
648temacs${EXEEXT}: $(START_FILES) stamp-oldxmenu ${obj} ${otherobj} 652temacs${EXEEXT}: $(START_FILES) stamp-oldxmenu ${obj} ${otherobj}
649 $(LD) ${TEMACS_LDFLAGS} ${TEMACS_LDFLAGS2} \ 653 $(CC) $(LD_FIRSTFLAG) ${TEMACS_LDFLAGS} ${TEMACS_LDFLAGS2} \
650 -o temacs ${START_FILES} ${obj} ${otherobj} ${LIBES} 654 -o temacs ${START_FILES} ${obj} ${otherobj} ${LIBES}
651 655
652## The following oldxmenu-related rules are only (possibly) used if 656## The following oldxmenu-related rules are only (possibly) used if
diff --git a/src/alloc.c b/src/alloc.c
index d83d8937722..f2bb28e2d96 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1643,7 +1643,7 @@ static int total_strings, total_free_strings;
1643 1643
1644/* Number of bytes used by live strings. */ 1644/* Number of bytes used by live strings. */
1645 1645
1646static int total_string_size; 1646static EMACS_INT total_string_size;
1647 1647
1648/* Given a pointer to a Lisp_String S which is on the free-list 1648/* Given a pointer to a Lisp_String S which is on the free-list
1649 string_free_list, return a pointer to its successor in the 1649 string_free_list, return a pointer to its successor in the
@@ -1738,11 +1738,12 @@ static void check_sblock (struct sblock *);
1738 1738
1739/* Like GC_STRING_BYTES, but with debugging check. */ 1739/* Like GC_STRING_BYTES, but with debugging check. */
1740 1740
1741int 1741EMACS_INT
1742string_bytes (s) 1742string_bytes (struct Lisp_String *s)
1743 struct Lisp_String *s;
1744{ 1743{
1745 int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); 1744 EMACS_INT nbytes =
1745 (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte);
1746
1746 if (!PURE_POINTER_P (s) 1747 if (!PURE_POINTER_P (s)
1747 && s->data 1748 && s->data
1748 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) 1749 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
@@ -1764,7 +1765,7 @@ check_sblock (b)
1764 { 1765 {
1765 /* Compute the next FROM here because copying below may 1766 /* Compute the next FROM here because copying below may
1766 overwrite data we need to compute it. */ 1767 overwrite data we need to compute it. */
1767 int nbytes; 1768 EMACS_INT nbytes;
1768 1769
1769 /* Check that the string size recorded in the string is the 1770 /* Check that the string size recorded in the string is the
1770 same as the one recorded in the sdata structure. */ 1771 same as the one recorded in the sdata structure. */
@@ -1824,7 +1825,7 @@ check_string_free_list ()
1824 s = string_free_list; 1825 s = string_free_list;
1825 while (s != NULL) 1826 while (s != NULL)
1826 { 1827 {
1827 if ((unsigned)s < 1024) 1828 if ((unsigned long)s < 1024)
1828 abort(); 1829 abort();
1829 s = NEXT_FREE_LISP_STRING (s); 1830 s = NEXT_FREE_LISP_STRING (s);
1830 } 1831 }
@@ -1907,11 +1908,12 @@ allocate_string (void)
1907 S->data if it was initially non-null. */ 1908 S->data if it was initially non-null. */
1908 1909
1909void 1910void
1910allocate_string_data (struct Lisp_String *s, int nchars, int nbytes) 1911allocate_string_data (struct Lisp_String *s,
1912 EMACS_INT nchars, EMACS_INT nbytes)
1911{ 1913{
1912 struct sdata *data, *old_data; 1914 struct sdata *data, *old_data;
1913 struct sblock *b; 1915 struct sblock *b;
1914 int needed, old_nbytes; 1916 EMACS_INT needed, old_nbytes;
1915 1917
1916 /* Determine the number of bytes needed to store NBYTES bytes 1918 /* Determine the number of bytes needed to store NBYTES bytes
1917 of string data. */ 1919 of string data. */
@@ -2153,7 +2155,7 @@ compact_small_strings (void)
2153 { 2155 {
2154 /* Compute the next FROM here because copying below may 2156 /* Compute the next FROM here because copying below may
2155 overwrite data we need to compute it. */ 2157 overwrite data we need to compute it. */
2156 int nbytes; 2158 EMACS_INT nbytes;
2157 2159
2158#ifdef GC_CHECK_STRING_BYTES 2160#ifdef GC_CHECK_STRING_BYTES
2159 /* Check that the string size recorded in the string is the 2161 /* Check that the string size recorded in the string is the
@@ -2231,7 +2233,8 @@ INIT must be an integer that represents a character. */)
2231{ 2233{
2232 register Lisp_Object val; 2234 register Lisp_Object val;
2233 register unsigned char *p, *end; 2235 register unsigned char *p, *end;
2234 int c, nbytes; 2236 int c;
2237 EMACS_INT nbytes;
2235 2238
2236 CHECK_NATNUM (length); 2239 CHECK_NATNUM (length);
2237 CHECK_NUMBER (init); 2240 CHECK_NUMBER (init);
@@ -2250,9 +2253,12 @@ INIT must be an integer that represents a character. */)
2250 { 2253 {
2251 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2254 unsigned char str[MAX_MULTIBYTE_LENGTH];
2252 int len = CHAR_STRING (c, str); 2255 int len = CHAR_STRING (c, str);
2256 EMACS_INT string_len = XINT (length);
2253 2257
2254 nbytes = len * XINT (length); 2258 if (string_len > MOST_POSITIVE_FIXNUM / len)
2255 val = make_uninit_multibyte_string (XINT (length), nbytes); 2259 error ("Maximum string size exceeded");
2260 nbytes = len * string_len;
2261 val = make_uninit_multibyte_string (string_len, nbytes);
2256 p = SDATA (val); 2262 p = SDATA (val);
2257 end = p + nbytes; 2263 end = p + nbytes;
2258 while (p != end) 2264 while (p != end)
@@ -2275,7 +2281,8 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
2275 register Lisp_Object val; 2281 register Lisp_Object val;
2276 struct Lisp_Bool_Vector *p; 2282 struct Lisp_Bool_Vector *p;
2277 int real_init, i; 2283 int real_init, i;
2278 int length_in_chars, length_in_elts, bits_per_value; 2284 EMACS_INT length_in_chars, length_in_elts;
2285 int bits_per_value;
2279 2286
2280 CHECK_NATNUM (length); 2287 CHECK_NATNUM (length);
2281 2288
@@ -2315,10 +2322,10 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
2315 multibyte, depending on the contents. */ 2322 multibyte, depending on the contents. */
2316 2323
2317Lisp_Object 2324Lisp_Object
2318make_string (const char *contents, int nbytes) 2325make_string (const char *contents, EMACS_INT nbytes)
2319{ 2326{
2320 register Lisp_Object val; 2327 register Lisp_Object val;
2321 int nchars, multibyte_nbytes; 2328 EMACS_INT nchars, multibyte_nbytes;
2322 2329
2323 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); 2330 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes);
2324 if (nbytes == nchars || nbytes != multibyte_nbytes) 2331 if (nbytes == nchars || nbytes != multibyte_nbytes)
@@ -2334,7 +2341,7 @@ make_string (const char *contents, int nbytes)
2334/* Make an unibyte string from LENGTH bytes at CONTENTS. */ 2341/* Make an unibyte string from LENGTH bytes at CONTENTS. */
2335 2342
2336Lisp_Object 2343Lisp_Object
2337make_unibyte_string (const char *contents, int length) 2344make_unibyte_string (const char *contents, EMACS_INT length)
2338{ 2345{
2339 register Lisp_Object val; 2346 register Lisp_Object val;
2340 val = make_uninit_string (length); 2347 val = make_uninit_string (length);
@@ -2348,7 +2355,8 @@ make_unibyte_string (const char *contents, int length)
2348 bytes at CONTENTS. */ 2355 bytes at CONTENTS. */
2349 2356
2350Lisp_Object 2357Lisp_Object
2351make_multibyte_string (const char *contents, int nchars, int nbytes) 2358make_multibyte_string (const char *contents,
2359 EMACS_INT nchars, EMACS_INT nbytes)
2352{ 2360{
2353 register Lisp_Object val; 2361 register Lisp_Object val;
2354 val = make_uninit_multibyte_string (nchars, nbytes); 2362 val = make_uninit_multibyte_string (nchars, nbytes);
@@ -2361,7 +2369,8 @@ make_multibyte_string (const char *contents, int nchars, int nbytes)
2361 CONTENTS. It is a multibyte string if NBYTES != NCHARS. */ 2369 CONTENTS. It is a multibyte string if NBYTES != NCHARS. */
2362 2370
2363Lisp_Object 2371Lisp_Object
2364make_string_from_bytes (const char *contents, int nchars, int nbytes) 2372make_string_from_bytes (const char *contents,
2373 EMACS_INT nchars, EMACS_INT nbytes)
2365{ 2374{
2366 register Lisp_Object val; 2375 register Lisp_Object val;
2367 val = make_uninit_multibyte_string (nchars, nbytes); 2376 val = make_uninit_multibyte_string (nchars, nbytes);
@@ -2378,7 +2387,8 @@ make_string_from_bytes (const char *contents, int nchars, int nbytes)
2378 characters by itself. */ 2387 characters by itself. */
2379 2388
2380Lisp_Object 2389Lisp_Object
2381make_specified_string (const char *contents, int nchars, int nbytes, int multibyte) 2390make_specified_string (const char *contents,
2391 EMACS_INT nchars, EMACS_INT nbytes, int multibyte)
2382{ 2392{
2383 register Lisp_Object val; 2393 register Lisp_Object val;
2384 2394
@@ -2411,7 +2421,7 @@ build_string (const char *str)
2411 occupying LENGTH bytes. */ 2421 occupying LENGTH bytes. */
2412 2422
2413Lisp_Object 2423Lisp_Object
2414make_uninit_string (int length) 2424make_uninit_string (EMACS_INT length)
2415{ 2425{
2416 Lisp_Object val; 2426 Lisp_Object val;
2417 2427
@@ -2427,7 +2437,7 @@ make_uninit_string (int length)
2427 which occupy NBYTES bytes. */ 2437 which occupy NBYTES bytes. */
2428 2438
2429Lisp_Object 2439Lisp_Object
2430make_uninit_multibyte_string (int nchars, int nbytes) 2440make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
2431{ 2441{
2432 Lisp_Object string; 2442 Lisp_Object string;
2433 struct Lisp_String *s; 2443 struct Lisp_String *s;
@@ -2766,7 +2776,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
2766 (register Lisp_Object length, Lisp_Object init) 2776 (register Lisp_Object length, Lisp_Object init)
2767{ 2777{
2768 register Lisp_Object val; 2778 register Lisp_Object val;
2769 register int size; 2779 register EMACS_INT size;
2770 2780
2771 CHECK_NATNUM (length); 2781 CHECK_NATNUM (length);
2772 size = XFASTINT (length); 2782 size = XFASTINT (length);
@@ -2944,7 +2954,7 @@ See also the function `vector'. */)
2944{ 2954{
2945 Lisp_Object vector; 2955 Lisp_Object vector;
2946 register EMACS_INT sizei; 2956 register EMACS_INT sizei;
2947 register int index; 2957 register EMACS_INT index;
2948 register struct Lisp_Vector *p; 2958 register struct Lisp_Vector *p;
2949 2959
2950 CHECK_NATNUM (length); 2960 CHECK_NATNUM (length);
@@ -3841,7 +3851,7 @@ live_string_p (struct mem_node *m, void *p)
3841 if (m->type == MEM_TYPE_STRING) 3851 if (m->type == MEM_TYPE_STRING)
3842 { 3852 {
3843 struct string_block *b = (struct string_block *) m->start; 3853 struct string_block *b = (struct string_block *) m->start;
3844 int offset = (char *) p - (char *) &b->strings[0]; 3854 ptrdiff_t offset = (char *) p - (char *) &b->strings[0];
3845 3855
3846 /* P must point to the start of a Lisp_String structure, and it 3856 /* P must point to the start of a Lisp_String structure, and it
3847 must not be on the free-list. */ 3857 must not be on the free-list. */
@@ -3864,7 +3874,7 @@ live_cons_p (struct mem_node *m, void *p)
3864 if (m->type == MEM_TYPE_CONS) 3874 if (m->type == MEM_TYPE_CONS)
3865 { 3875 {
3866 struct cons_block *b = (struct cons_block *) m->start; 3876 struct cons_block *b = (struct cons_block *) m->start;
3867 int offset = (char *) p - (char *) &b->conses[0]; 3877 ptrdiff_t offset = (char *) p - (char *) &b->conses[0];
3868 3878
3869 /* P must point to the start of a Lisp_Cons, not be 3879 /* P must point to the start of a Lisp_Cons, not be
3870 one of the unused cells in the current cons block, 3880 one of the unused cells in the current cons block,
@@ -3890,7 +3900,7 @@ live_symbol_p (struct mem_node *m, void *p)
3890 if (m->type == MEM_TYPE_SYMBOL) 3900 if (m->type == MEM_TYPE_SYMBOL)
3891 { 3901 {
3892 struct symbol_block *b = (struct symbol_block *) m->start; 3902 struct symbol_block *b = (struct symbol_block *) m->start;
3893 int offset = (char *) p - (char *) &b->symbols[0]; 3903 ptrdiff_t offset = (char *) p - (char *) &b->symbols[0];
3894 3904
3895 /* P must point to the start of a Lisp_Symbol, not be 3905 /* P must point to the start of a Lisp_Symbol, not be
3896 one of the unused cells in the current symbol block, 3906 one of the unused cells in the current symbol block,
@@ -3916,7 +3926,7 @@ live_float_p (struct mem_node *m, void *p)
3916 if (m->type == MEM_TYPE_FLOAT) 3926 if (m->type == MEM_TYPE_FLOAT)
3917 { 3927 {
3918 struct float_block *b = (struct float_block *) m->start; 3928 struct float_block *b = (struct float_block *) m->start;
3919 int offset = (char *) p - (char *) &b->floats[0]; 3929 ptrdiff_t offset = (char *) p - (char *) &b->floats[0];
3920 3930
3921 /* P must point to the start of a Lisp_Float and not be 3931 /* P must point to the start of a Lisp_Float and not be
3922 one of the unused cells in the current float block. */ 3932 one of the unused cells in the current float block. */
@@ -3940,7 +3950,7 @@ live_misc_p (struct mem_node *m, void *p)
3940 if (m->type == MEM_TYPE_MISC) 3950 if (m->type == MEM_TYPE_MISC)
3941 { 3951 {
3942 struct marker_block *b = (struct marker_block *) m->start; 3952 struct marker_block *b = (struct marker_block *) m->start;
3943 int offset = (char *) p - (char *) &b->markers[0]; 3953 ptrdiff_t offset = (char *) p - (char *) &b->markers[0];
3944 3954
3945 /* P must point to the start of a Lisp_Misc, not be 3955 /* P must point to the start of a Lisp_Misc, not be
3946 one of the unused cells in the current misc block, 3956 one of the unused cells in the current misc block,
@@ -4647,9 +4657,10 @@ check_pure_size (void)
4647 address. Return NULL if not found. */ 4657 address. Return NULL if not found. */
4648 4658
4649static char * 4659static char *
4650find_string_data_in_pure (const char *data, int nbytes) 4660find_string_data_in_pure (const char *data, EMACS_INT nbytes)
4651{ 4661{
4652 int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max; 4662 int i;
4663 EMACS_INT skip, bm_skip[256], last_char_skip, infinity, start, start_max;
4653 const unsigned char *p; 4664 const unsigned char *p;
4654 char *non_lisp_beg; 4665 char *non_lisp_beg;
4655 4666
@@ -4716,7 +4727,8 @@ find_string_data_in_pure (const char *data, int nbytes)
4716 string; then the string is not protected from gc. */ 4727 string; then the string is not protected from gc. */
4717 4728
4718Lisp_Object 4729Lisp_Object
4719make_pure_string (const char *data, int nchars, int nbytes, int multibyte) 4730make_pure_string (const char *data,
4731 EMACS_INT nchars, EMACS_INT nbytes, int multibyte)
4720{ 4732{
4721 Lisp_Object string; 4733 Lisp_Object string;
4722 struct Lisp_String *s; 4734 struct Lisp_String *s;
@@ -4744,7 +4756,7 @@ make_pure_c_string (const char *data)
4744{ 4756{
4745 Lisp_Object string; 4757 Lisp_Object string;
4746 struct Lisp_String *s; 4758 struct Lisp_String *s;
4747 int nchars = strlen (data); 4759 EMACS_INT nchars = strlen (data);
4748 4760
4749 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); 4761 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
4750 s->size = nchars; 4762 s->size = nchars;
@@ -4834,7 +4846,7 @@ Does not copy symbols. Copies strings without text properties. */)
4834 else if (FUNVECP (obj) || VECTORP (obj)) 4846 else if (FUNVECP (obj) || VECTORP (obj))
4835 { 4847 {
4836 register struct Lisp_Vector *vec; 4848 register struct Lisp_Vector *vec;
4837 register int i; 4849 register EMACS_INT i;
4838 EMACS_INT size; 4850 EMACS_INT size;
4839 4851
4840 size = XVECTOR (obj)->size; 4852 size = XVECTOR (obj)->size;
@@ -5283,8 +5295,8 @@ static int mark_object_loop_halt;
5283static void 5295static void
5284mark_vectorlike (struct Lisp_Vector *ptr) 5296mark_vectorlike (struct Lisp_Vector *ptr)
5285{ 5297{
5286 register EMACS_INT size = ptr->size; 5298 register EMACS_UINT size = ptr->size;
5287 register int i; 5299 register EMACS_UINT i;
5288 5300
5289 eassert (!VECTOR_MARKED_P (ptr)); 5301 eassert (!VECTOR_MARKED_P (ptr));
5290 VECTOR_MARK (ptr); /* Else mark it */ 5302 VECTOR_MARK (ptr); /* Else mark it */
@@ -5306,8 +5318,8 @@ mark_vectorlike (struct Lisp_Vector *ptr)
5306static void 5318static void
5307mark_char_table (struct Lisp_Vector *ptr) 5319mark_char_table (struct Lisp_Vector *ptr)
5308{ 5320{
5309 register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; 5321 register EMACS_UINT size = ptr->size & PSEUDOVECTOR_SIZE_MASK;
5310 register int i; 5322 register EMACS_UINT i;
5311 5323
5312 eassert (!VECTOR_MARKED_P (ptr)); 5324 eassert (!VECTOR_MARKED_P (ptr));
5313 VECTOR_MARK (ptr); 5325 VECTOR_MARK (ptr);
@@ -5436,8 +5448,8 @@ mark_object (Lisp_Object arg)
5436 recursion there. */ 5448 recursion there. */
5437 { 5449 {
5438 register struct Lisp_Vector *ptr = XVECTOR (obj); 5450 register struct Lisp_Vector *ptr = XVECTOR (obj);
5439 register EMACS_INT size = ptr->size; 5451 register EMACS_UINT size = ptr->size;
5440 register int i; 5452 register EMACS_UINT i;
5441 5453
5442 CHECK_LIVE (live_vector_p); 5454 CHECK_LIVE (live_vector_p);
5443 VECTOR_MARK (ptr); /* Else mark it */ 5455 VECTOR_MARK (ptr); /* Else mark it */
diff --git a/src/bidi.c b/src/bidi.c
index a6d4d1b2506..b7c6fdc2ddd 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -79,10 +79,10 @@ static Lisp_Object bidi_type_table, bidi_mirror_table;
79 79
80/* What we need to know about the current paragraph. */ 80/* What we need to know about the current paragraph. */
81struct bidi_paragraph_info { 81struct bidi_paragraph_info {
82 int start_bytepos; /* byte position where it begins */ 82 EMACS_INT start_bytepos; /* byte position where it begins */
83 int end_bytepos; /* byte position where it ends */ 83 EMACS_INT end_bytepos; /* byte position where it ends */
84 int embedding_level; /* its basic embedding level */ 84 int embedding_level; /* its basic embedding level */
85 bidi_dir_t base_dir; /* its base direction */ 85 bidi_dir_t base_dir; /* its base direction */
86}; 86};
87 87
88/* Data type for describing the bidirectional character categories. */ 88/* Data type for describing the bidirectional character categories. */
@@ -313,7 +313,7 @@ bidi_cache_fetch_state (int idx, struct bidi_it *bidi_it)
313 resolved levels in cached states. DIR, if non-zero, means search 313 resolved levels in cached states. DIR, if non-zero, means search
314 in that direction from the last cache hit. */ 314 in that direction from the last cache hit. */
315static INLINE int 315static INLINE int
316bidi_cache_search (int charpos, int level, int dir) 316bidi_cache_search (EMACS_INT charpos, int level, int dir)
317{ 317{
318 int i, i_start; 318 int i, i_start;
319 319
@@ -462,7 +462,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved)
462} 462}
463 463
464static INLINE bidi_type_t 464static INLINE bidi_type_t
465bidi_cache_find (int charpos, int level, struct bidi_it *bidi_it) 465bidi_cache_find (EMACS_INT charpos, int level, struct bidi_it *bidi_it)
466{ 466{
467 int i = bidi_cache_search (charpos, level, bidi_it->scan_dir); 467 int i = bidi_cache_search (charpos, level, bidi_it->scan_dir);
468 468
@@ -583,18 +583,26 @@ bidi_find_paragraph_start (EMACS_INT pos, EMACS_INT pos_byte)
583 return pos_byte; 583 return pos_byte;
584} 584}
585 585
586/* Determine the direction, a.k.a. base embedding level, of the 586/* Determine the base direction, a.k.a. base embedding level, of the
587 paragraph we are about to iterate through. If DIR is either L2R or 587 paragraph we are about to iterate through. If DIR is either L2R or
588 R2L, just use that. Otherwise, determine the paragraph direction 588 R2L, just use that. Otherwise, determine the paragraph direction
589 from the first strong character of the paragraph. 589 from the first strong directional character of the paragraph.
590 590
591 Note that this gives the paragraph separator the same direction as 591 NO_DEFAULT_P non-nil means don't default to L2R if the paragraph
592 the preceding paragraph, even though Emacs generally views the 592 has no strong directional characters and both DIR and
593 separartor as not belonging to any paragraph. */ 593 bidi_it->paragraph_dir are NEUTRAL_DIR. In that case, search back
594 in the buffer until a paragraph is found with a strong character,
595 or until hitting BEGV. In the latter case, fall back to L2R. This
596 flag is used in current-bidi-paragraph-direction.
597
598 Note that this function gives the paragraph separator the same
599 direction as the preceding paragraph, even though Emacs generally
600 views the separartor as not belonging to any paragraph. */
594void 601void
595bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it) 602bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
596{ 603{
597 EMACS_INT bytepos = bidi_it->bytepos; 604 EMACS_INT bytepos = bidi_it->bytepos;
605 EMACS_INT pstartbyte;
598 606
599 /* Special case for an empty buffer. */ 607 /* Special case for an empty buffer. */
600 if (bytepos == BEGV_BYTE && bytepos == ZV_BYTE) 608 if (bytepos == BEGV_BYTE && bytepos == ZV_BYTE)
@@ -643,49 +651,75 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it)
643 651
644 /* We are either at the beginning of a paragraph or in the 652 /* We are either at the beginning of a paragraph or in the
645 middle of it. Find where this paragraph starts. */ 653 middle of it. Find where this paragraph starts. */
646 bytepos = bidi_find_paragraph_start (pos, bytepos); 654 pstartbyte = bidi_find_paragraph_start (pos, bytepos);
647
648 bidi_it->separator_limit = -1; 655 bidi_it->separator_limit = -1;
649 bidi_it->new_paragraph = 0; 656 bidi_it->new_paragraph = 0;
650 ch = FETCH_CHAR (bytepos); 657
651 ch_len = CHAR_BYTES (ch); 658 /* The following loop is run more than once only if NO_DEFAULT_P
652 pos = BYTE_TO_CHAR (bytepos); 659 is non-zero. */
653 type = bidi_get_type (ch, NEUTRAL_DIR); 660 do {
654 661 bytepos = pstartbyte;
655 for (pos++, bytepos += ch_len; 662 ch = FETCH_CHAR (bytepos);
656 /* NOTE: UAX#9 says to search only for L, AL, or R types of 663 ch_len = CHAR_BYTES (ch);
657 characters, and ignore RLE, RLO, LRE, and LRO. However, 664 pos = BYTE_TO_CHAR (bytepos);
658 I'm not sure it makes sense to omit those 4; should try 665 type = bidi_get_type (ch, NEUTRAL_DIR);
659 with and without that to see the effect. */ 666
660 (bidi_get_category (type) != STRONG) 667 for (pos++, bytepos += ch_len;
661 || (bidi_ignore_explicit_marks_for_paragraph_level 668 /* NOTE: UAX#9 says to search only for L, AL, or R types
662 && (type == RLE || type == RLO 669 of characters, and ignore RLE, RLO, LRE, and LRO.
663 || type == LRE || type == LRO)); 670 However, I'm not sure it makes sense to omit those 4;
664 type = bidi_get_type (ch, NEUTRAL_DIR)) 671 should try with and without that to see the effect. */
665 { 672 (bidi_get_category (type) != STRONG)
666 if (type == NEUTRAL_B && bidi_at_paragraph_end (pos, bytepos) >= -1) 673 || (bidi_ignore_explicit_marks_for_paragraph_level
667 break; 674 && (type == RLE || type == RLO
668 if (bytepos >= ZV_BYTE) 675 || type == LRE || type == LRO));
669 { 676 type = bidi_get_type (ch, NEUTRAL_DIR))
670 /* Pretend there's a paragraph separator at end of buffer. */ 677 {
671 type = NEUTRAL_B; 678 if (type == NEUTRAL_B && bidi_at_paragraph_end (pos, bytepos) >= -1)
672 break; 679 break;
673 } 680 if (bytepos >= ZV_BYTE)
674 FETCH_CHAR_ADVANCE (ch, pos, bytepos); 681 {
675 } 682 /* Pretend there's a paragraph separator at end of
676 if (type == STRONG_R || type == STRONG_AL) /* P3 */ 683 buffer. */
677 bidi_it->paragraph_dir = R2L; 684 type = NEUTRAL_B;
678 else if (type == STRONG_L) 685 break;
679 bidi_it->paragraph_dir = L2R; 686 }
687 FETCH_CHAR_ADVANCE (ch, pos, bytepos);
688 }
689 if (type == STRONG_R || type == STRONG_AL) /* P3 */
690 bidi_it->paragraph_dir = R2L;
691 else if (type == STRONG_L)
692 bidi_it->paragraph_dir = L2R;
693 if (no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR)
694 {
695 /* If this paragraph is at BEGV, default to L2R. */
696 if (pstartbyte == BEGV_BYTE)
697 bidi_it->paragraph_dir = L2R; /* P3 and HL1 */
698 else
699 {
700 EMACS_INT prevpbyte = pstartbyte;
701 EMACS_INT p = BYTE_TO_CHAR (pstartbyte), pbyte = pstartbyte;
702
703 /* Find the beginning of the previous paragraph, if any. */
704 while (pbyte > BEGV_BYTE && prevpbyte >= pstartbyte)
705 {
706 p--;
707 pbyte = CHAR_TO_BYTE (p);
708 prevpbyte = bidi_find_paragraph_start (p, pbyte);
709 }
710 pstartbyte = prevpbyte;
711 }
712 }
713 } while (no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR);
680 } 714 }
681 else 715 else
682 abort (); 716 abort ();
683 717
684 /* Contrary to UAX#9 clause P3, we only default the paragraph 718 /* Contrary to UAX#9 clause P3, we only default the paragraph
685 direction to L2R if we have no previous usable paragraph 719 direction to L2R if we have no previous usable paragraph
686 direction. */ 720 direction. This is allowed by the HL1 clause. */
687 if (bidi_it->paragraph_dir != L2R && bidi_it->paragraph_dir != R2L) 721 if (bidi_it->paragraph_dir != L2R && bidi_it->paragraph_dir != R2L)
688 bidi_it->paragraph_dir = L2R; /* P3 and ``higher protocols'' */ 722 bidi_it->paragraph_dir = L2R; /* P3 and HL1 ``higher-level protocols'' */
689 if (bidi_it->paragraph_dir == R2L) 723 if (bidi_it->paragraph_dir == R2L)
690 bidi_it->level_stack[0].level = 1; 724 bidi_it->level_stack[0].level = 1;
691 else 725 else
diff --git a/src/buffer.c b/src/buffer.c
index 86a638eb230..6b6b6efc633 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2092,7 +2092,7 @@ validate_region (register Lisp_Object *b, register Lisp_Object *e)
2092 and return the adjusted position. */ 2092 and return the adjusted position. */
2093 2093
2094static int 2094static int
2095advance_to_char_boundary (int byte_pos) 2095advance_to_char_boundary (EMACS_INT byte_pos)
2096{ 2096{
2097 int c; 2097 int c;
2098 2098
@@ -2105,7 +2105,7 @@ advance_to_char_boundary (int byte_pos)
2105 { 2105 {
2106 /* We should advance BYTE_POS only when C is a constituent of a 2106 /* We should advance BYTE_POS only when C is a constituent of a
2107 multibyte sequence. */ 2107 multibyte sequence. */
2108 int orig_byte_pos = byte_pos; 2108 EMACS_INT orig_byte_pos = byte_pos;
2109 2109
2110 do 2110 do
2111 { 2111 {
@@ -2273,7 +2273,7 @@ current buffer is cleared. */)
2273{ 2273{
2274 struct Lisp_Marker *tail, *markers; 2274 struct Lisp_Marker *tail, *markers;
2275 struct buffer *other; 2275 struct buffer *other;
2276 int begv, zv; 2276 EMACS_INT begv, zv;
2277 int narrowed = (BEG != BEGV || Z != ZV); 2277 int narrowed = (BEG != BEGV || Z != ZV);
2278 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2278 int modified_p = !NILP (Fbuffer_modified_p (Qnil));
2279 Lisp_Object old_undo = current_buffer->undo_list; 2279 Lisp_Object old_undo = current_buffer->undo_list;
@@ -2305,7 +2305,7 @@ current buffer is cleared. */)
2305 2305
2306 if (NILP (flag)) 2306 if (NILP (flag))
2307 { 2307 {
2308 int pos, stop; 2308 EMACS_INT pos, stop;
2309 unsigned char *p; 2309 unsigned char *p;
2310 2310
2311 /* Do this first, so it can use CHAR_TO_BYTE 2311 /* Do this first, so it can use CHAR_TO_BYTE
@@ -2345,7 +2345,7 @@ current buffer is cleared. */)
2345 { 2345 {
2346 c = STRING_CHAR_AND_LENGTH (p, bytes); 2346 c = STRING_CHAR_AND_LENGTH (p, bytes);
2347 /* Delete all bytes for this 8-bit character but the 2347 /* Delete all bytes for this 8-bit character but the
2348 last one, and change the last one to the charcter 2348 last one, and change the last one to the character
2349 code. */ 2349 code. */
2350 bytes--; 2350 bytes--;
2351 del_range_2 (pos, pos, pos + bytes, pos + bytes, 0); 2351 del_range_2 (pos, pos, pos + bytes, pos + bytes, 0);
@@ -2369,8 +2369,8 @@ current buffer is cleared. */)
2369 } 2369 }
2370 else 2370 else
2371 { 2371 {
2372 int pt = PT; 2372 EMACS_INT pt = PT;
2373 int pos, stop; 2373 EMACS_INT pos, stop;
2374 unsigned char *p, *pend; 2374 unsigned char *p, *pend;
2375 2375
2376 /* Be sure not to have a multibyte sequence striding over the GAP. 2376 /* Be sure not to have a multibyte sequence striding over the GAP.
@@ -2386,7 +2386,7 @@ current buffer is cleared. */)
2386 while (! CHAR_HEAD_P (*p) && p > BEG_ADDR) p--; 2386 while (! CHAR_HEAD_P (*p) && p > BEG_ADDR) p--;
2387 if (LEADING_CODE_P (*p)) 2387 if (LEADING_CODE_P (*p))
2388 { 2388 {
2389 int new_gpt = GPT_BYTE - (GPT_ADDR - p); 2389 EMACS_INT new_gpt = GPT_BYTE - (GPT_ADDR - p);
2390 2390
2391 move_gap_both (new_gpt, new_gpt); 2391 move_gap_both (new_gpt, new_gpt);
2392 } 2392 }
@@ -2470,8 +2470,8 @@ current buffer is cleared. */)
2470 ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG; 2470 ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG;
2471 2471
2472 { 2472 {
2473 int pt_byte = advance_to_char_boundary (PT_BYTE); 2473 EMACS_INT pt_byte = advance_to_char_boundary (PT_BYTE);
2474 int pt; 2474 EMACS_INT pt;
2475 2475
2476 if (pt_byte > GPT_BYTE) 2476 if (pt_byte > GPT_BYTE)
2477 pt = chars_in_text (GAP_END_ADDR, pt_byte - GPT_BYTE) + GPT; 2477 pt = chars_in_text (GAP_END_ADDR, pt_byte - GPT_BYTE) + GPT;
@@ -2642,13 +2642,13 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, int *len_ptr,
2642 int idx = 0; 2642 int idx = 0;
2643 int len = *len_ptr; 2643 int len = *len_ptr;
2644 Lisp_Object *vec = *vec_ptr; 2644 Lisp_Object *vec = *vec_ptr;
2645 int next = ZV; 2645 EMACS_INT next = ZV;
2646 int prev = BEGV; 2646 EMACS_INT prev = BEGV;
2647 int inhibit_storing = 0; 2647 int inhibit_storing = 0;
2648 2648
2649 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2649 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2650 { 2650 {
2651 int startpos, endpos; 2651 EMACS_INT startpos, endpos;
2652 2652
2653 XSETMISC (overlay, tail); 2653 XSETMISC (overlay, tail);
2654 2654
@@ -2699,7 +2699,7 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, int *len_ptr,
2699 2699
2700 for (tail = current_buffer->overlays_after; tail; tail = tail->next) 2700 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
2701 { 2701 {
2702 int startpos, endpos; 2702 EMACS_INT startpos, endpos;
2703 2703
2704 XSETMISC (overlay, tail); 2704 XSETMISC (overlay, tail);
2705 2705
@@ -2773,22 +2773,23 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, int *len_ptr,
2773 But we still return the total number of overlays. */ 2773 But we still return the total number of overlays. */
2774 2774
2775static int 2775static int
2776overlays_in (int beg, int end, int extend, Lisp_Object **vec_ptr, int *len_ptr, 2776overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
2777 int *next_ptr, int *prev_ptr) 2777 Lisp_Object **vec_ptr, int *len_ptr,
2778 EMACS_INT *next_ptr, EMACS_INT *prev_ptr)
2778{ 2779{
2779 Lisp_Object overlay, ostart, oend; 2780 Lisp_Object overlay, ostart, oend;
2780 struct Lisp_Overlay *tail; 2781 struct Lisp_Overlay *tail;
2781 int idx = 0; 2782 int idx = 0;
2782 int len = *len_ptr; 2783 int len = *len_ptr;
2783 Lisp_Object *vec = *vec_ptr; 2784 Lisp_Object *vec = *vec_ptr;
2784 int next = ZV; 2785 EMACS_INT next = ZV;
2785 int prev = BEGV; 2786 EMACS_INT prev = BEGV;
2786 int inhibit_storing = 0; 2787 int inhibit_storing = 0;
2787 int end_is_Z = end == Z; 2788 int end_is_Z = end == Z;
2788 2789
2789 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2790 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2790 { 2791 {
2791 int startpos, endpos; 2792 EMACS_INT startpos, endpos;
2792 2793
2793 XSETMISC (overlay, tail); 2794 XSETMISC (overlay, tail);
2794 2795
@@ -2838,7 +2839,7 @@ overlays_in (int beg, int end, int extend, Lisp_Object **vec_ptr, int *len_ptr,
2838 2839
2839 for (tail = current_buffer->overlays_after; tail; tail = tail->next) 2840 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
2840 { 2841 {
2841 int startpos, endpos; 2842 EMACS_INT startpos, endpos;
2842 2843
2843 XSETMISC (overlay, tail); 2844 XSETMISC (overlay, tail);
2844 2845
@@ -2897,8 +2898,8 @@ overlays_in (int beg, int end, int extend, Lisp_Object **vec_ptr, int *len_ptr,
2897int 2898int
2898mouse_face_overlay_overlaps (Lisp_Object overlay) 2899mouse_face_overlay_overlaps (Lisp_Object overlay)
2899{ 2900{
2900 int start = OVERLAY_POSITION (OVERLAY_START (overlay)); 2901 EMACS_INT start = OVERLAY_POSITION (OVERLAY_START (overlay));
2901 int end = OVERLAY_POSITION (OVERLAY_END (overlay)); 2902 EMACS_INT end = OVERLAY_POSITION (OVERLAY_END (overlay));
2902 int n, i, size; 2903 int n, i, size;
2903 Lisp_Object *v, tem; 2904 Lisp_Object *v, tem;
2904 2905
@@ -2924,14 +2925,14 @@ mouse_face_overlay_overlaps (Lisp_Object overlay)
2924 2925
2925/* Fast function to just test if we're at an overlay boundary. */ 2926/* Fast function to just test if we're at an overlay boundary. */
2926int 2927int
2927overlay_touches_p (int pos) 2928overlay_touches_p (EMACS_INT pos)
2928{ 2929{
2929 Lisp_Object overlay; 2930 Lisp_Object overlay;
2930 struct Lisp_Overlay *tail; 2931 struct Lisp_Overlay *tail;
2931 2932
2932 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2933 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2933 { 2934 {
2934 int endpos; 2935 EMACS_INT endpos;
2935 2936
2936 XSETMISC (overlay ,tail); 2937 XSETMISC (overlay ,tail);
2937 if (!OVERLAYP (overlay)) 2938 if (!OVERLAYP (overlay))
@@ -2946,7 +2947,7 @@ overlay_touches_p (int pos)
2946 2947
2947 for (tail = current_buffer->overlays_after; tail; tail = tail->next) 2948 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
2948 { 2949 {
2949 int startpos; 2950 EMACS_INT startpos;
2950 2951
2951 XSETMISC (overlay, tail); 2952 XSETMISC (overlay, tail);
2952 if (!OVERLAYP (overlay)) 2953 if (!OVERLAYP (overlay))
@@ -2964,7 +2965,7 @@ overlay_touches_p (int pos)
2964struct sortvec 2965struct sortvec
2965{ 2966{
2966 Lisp_Object overlay; 2967 Lisp_Object overlay;
2967 int beg, end; 2968 EMACS_INT beg, end;
2968 int priority; 2969 int priority;
2969}; 2970};
2970 2971
@@ -3051,7 +3052,7 @@ struct sortstrlist
3051 struct sortstr *buf; /* An array that expands as needed; never freed. */ 3052 struct sortstr *buf; /* An array that expands as needed; never freed. */
3052 int size; /* Allocated length of that array. */ 3053 int size; /* Allocated length of that array. */
3053 int used; /* How much of the array is currently in use. */ 3054 int used; /* How much of the array is currently in use. */
3054 int bytes; /* Total length of the strings in buf. */ 3055 EMACS_INT bytes; /* Total length of the strings in buf. */
3055}; 3056};
3056 3057
3057/* Buffers for storing information about the overlays touching a given 3058/* Buffers for storing information about the overlays touching a given
@@ -3062,7 +3063,7 @@ static struct sortstrlist overlay_heads, overlay_tails;
3062static unsigned char *overlay_str_buf; 3063static unsigned char *overlay_str_buf;
3063 3064
3064/* Allocated length of overlay_str_buf. */ 3065/* Allocated length of overlay_str_buf. */
3065static int overlay_str_len; 3066static EMACS_INT overlay_str_len;
3066 3067
3067/* A comparison function suitable for passing to qsort. */ 3068/* A comparison function suitable for passing to qsort. */
3068static int 3069static int
@@ -3080,7 +3081,7 @@ cmp_for_strings (const void *as1, const void *as2)
3080static void 3081static void
3081record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, Lisp_Object str2, Lisp_Object pri, int size) 3082record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, Lisp_Object str2, Lisp_Object pri, int size)
3082{ 3083{
3083 int nbytes; 3084 EMACS_INT nbytes;
3084 3085
3085 if (ssl->used == ssl->size) 3086 if (ssl->used == ssl->size)
3086 { 3087 {
@@ -3133,12 +3134,12 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, Lisp_Object str
3133 PSTR, if that variable is non-null. The string may be overwritten by 3134 PSTR, if that variable is non-null. The string may be overwritten by
3134 subsequent calls. */ 3135 subsequent calls. */
3135 3136
3136int 3137EMACS_INT
3137overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) 3138overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr)
3138{ 3139{
3139 Lisp_Object overlay, window, str; 3140 Lisp_Object overlay, window, str;
3140 struct Lisp_Overlay *ov; 3141 struct Lisp_Overlay *ov;
3141 int startpos, endpos; 3142 EMACS_INT startpos, endpos;
3142 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 3143 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
3143 3144
3144 overlay_heads.used = overlay_heads.bytes = 0; 3145 overlay_heads.used = overlay_heads.bytes = 0;
@@ -3208,9 +3209,9 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr)
3208 if (overlay_heads.bytes || overlay_tails.bytes) 3209 if (overlay_heads.bytes || overlay_tails.bytes)
3209 { 3210 {
3210 Lisp_Object tem; 3211 Lisp_Object tem;
3211 int i; 3212 EMACS_INT i;
3212 unsigned char *p; 3213 unsigned char *p;
3213 int total = overlay_heads.bytes + overlay_tails.bytes; 3214 EMACS_INT total = overlay_heads.bytes + overlay_tails.bytes;
3214 3215
3215 if (total > overlay_str_len) 3216 if (total > overlay_str_len)
3216 { 3217 {
@@ -3221,7 +3222,7 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr)
3221 p = overlay_str_buf; 3222 p = overlay_str_buf;
3222 for (i = overlay_tails.used; --i >= 0;) 3223 for (i = overlay_tails.used; --i >= 0;)
3223 { 3224 {
3224 int nbytes; 3225 EMACS_INT nbytes;
3225 tem = overlay_tails.buf[i].string; 3226 tem = overlay_tails.buf[i].string;
3226 nbytes = copy_text (SDATA (tem), p, 3227 nbytes = copy_text (SDATA (tem), p,
3227 SBYTES (tem), 3228 SBYTES (tem),
@@ -3230,7 +3231,7 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr)
3230 } 3231 }
3231 for (i = 0; i < overlay_heads.used; ++i) 3232 for (i = 0; i < overlay_heads.used; ++i)
3232 { 3233 {
3233 int nbytes; 3234 EMACS_INT nbytes;
3234 tem = overlay_heads.buf[i].string; 3235 tem = overlay_heads.buf[i].string;
3235 nbytes = copy_text (SDATA (tem), p, 3236 nbytes = copy_text (SDATA (tem), p,
3236 SBYTES (tem), 3237 SBYTES (tem),
@@ -3295,7 +3296,7 @@ recenter_overlay_lists (struct buffer *buf, EMACS_INT pos)
3295 if (OVERLAY_POSITION (end) > pos) 3296 if (OVERLAY_POSITION (end) > pos)
3296 { 3297 {
3297 /* OVERLAY needs to be moved. */ 3298 /* OVERLAY needs to be moved. */
3298 int where = OVERLAY_POSITION (beg); 3299 EMACS_INT where = OVERLAY_POSITION (beg);
3299 struct Lisp_Overlay *other, *other_prev; 3300 struct Lisp_Overlay *other, *other_prev;
3300 3301
3301 /* Splice the cons cell TAIL out of overlays_before. */ 3302 /* Splice the cons cell TAIL out of overlays_before. */
@@ -3368,7 +3369,7 @@ recenter_overlay_lists (struct buffer *buf, EMACS_INT pos)
3368 if (OVERLAY_POSITION (end) <= pos) 3369 if (OVERLAY_POSITION (end) <= pos)
3369 { 3370 {
3370 /* OVERLAY needs to be moved. */ 3371 /* OVERLAY needs to be moved. */
3371 int where = OVERLAY_POSITION (end); 3372 EMACS_INT where = OVERLAY_POSITION (end);
3372 struct Lisp_Overlay *other, *other_prev; 3373 struct Lisp_Overlay *other, *other_prev;
3373 3374
3374 /* Splice the cons cell TAIL out of overlays_after. */ 3375 /* Splice the cons cell TAIL out of overlays_after. */
@@ -3440,7 +3441,7 @@ adjust_overlays_for_delete (EMACS_INT pos, EMACS_INT length)
3440 Such an overlay might even have negative size at this point. 3441 Such an overlay might even have negative size at this point.
3441 If so, we'll make the overlay empty. */ 3442 If so, we'll make the overlay empty. */
3442void 3443void
3443fix_start_end_in_overlays (register int start, register int end) 3444fix_start_end_in_overlays (register EMACS_INT start, register EMACS_INT end)
3444{ 3445{
3445 Lisp_Object overlay; 3446 Lisp_Object overlay;
3446 struct Lisp_Overlay *before_list, *after_list; 3447 struct Lisp_Overlay *before_list, *after_list;
@@ -3452,7 +3453,7 @@ fix_start_end_in_overlays (register int start, register int end)
3452 current_buffer->overlays_before or overlays_after, depending 3453 current_buffer->overlays_before or overlays_after, depending
3453 which loop we're in. */ 3454 which loop we're in. */
3454 struct Lisp_Overlay *tail, *parent; 3455 struct Lisp_Overlay *tail, *parent;
3455 int startpos, endpos; 3456 EMACS_INT startpos, endpos;
3456 3457
3457 /* This algorithm shifts links around instead of consing and GCing. 3458 /* This algorithm shifts links around instead of consing and GCing.
3458 The loop invariant is that before_list (resp. after_list) is a 3459 The loop invariant is that before_list (resp. after_list) is a
@@ -3753,7 +3754,7 @@ modify_overlay (struct buffer *buf, EMACS_INT start, EMACS_INT end)
3753{ 3754{
3754 if (start > end) 3755 if (start > end)
3755 { 3756 {
3756 int temp = start; 3757 EMACS_INT temp = start;
3757 start = end; 3758 start = end;
3758 end = temp; 3759 end = temp;
3759 } 3760 }
@@ -3844,8 +3845,8 @@ buffer. */)
3844 /* Redisplay where the overlay was. */ 3845 /* Redisplay where the overlay was. */
3845 if (!NILP (obuffer)) 3846 if (!NILP (obuffer))
3846 { 3847 {
3847 int o_beg; 3848 EMACS_INT o_beg;
3848 int o_end; 3849 EMACS_INT o_end;
3849 3850
3850 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); 3851 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
3851 o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); 3852 o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
@@ -3859,7 +3860,7 @@ buffer. */)
3859 else 3860 else
3860 /* Redisplay the area the overlay has just left, or just enclosed. */ 3861 /* Redisplay the area the overlay has just left, or just enclosed. */
3861 { 3862 {
3862 int o_beg, o_end; 3863 EMACS_INT o_beg, o_end;
3863 3864
3864 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); 3865 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
3865 o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); 3866 o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
@@ -4037,7 +4038,7 @@ end of the buffer. */)
4037 /* Put all the overlays we want in a vector in overlay_vec. 4038 /* Put all the overlays we want in a vector in overlay_vec.
4038 Store the length in len. */ 4039 Store the length in len. */
4039 noverlays = overlays_in (XINT (beg), XINT (end), 1, &overlay_vec, &len, 4040 noverlays = overlays_in (XINT (beg), XINT (end), 1, &overlay_vec, &len,
4040 (int *) 0, (int *) 0); 4041 NULL, NULL);
4041 4042
4042 /* Make a list of them all. */ 4043 /* Make a list of them all. */
4043 result = Flist (noverlays, overlay_vec); 4044 result = Flist (noverlays, overlay_vec);
@@ -4280,7 +4281,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4280 last_overlay_modification_hooks_used = 0; 4281 last_overlay_modification_hooks_used = 0;
4281 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 4282 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
4282 { 4283 {
4283 int startpos, endpos; 4284 EMACS_INT startpos, endpos;
4284 Lisp_Object ostart, oend; 4285 Lisp_Object ostart, oend;
4285 4286
4286 XSETMISC (overlay, tail); 4287 XSETMISC (overlay, tail);
@@ -4317,7 +4318,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4317 4318
4318 for (tail = current_buffer->overlays_after; tail; tail = tail->next) 4319 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
4319 { 4320 {
4320 int startpos, endpos; 4321 EMACS_INT startpos, endpos;
4321 Lisp_Object ostart, oend; 4322 Lisp_Object ostart, oend;
4322 4323
4323 XSETMISC (overlay, tail); 4324 XSETMISC (overlay, tail);
@@ -4409,7 +4410,7 @@ evaporate_overlays (EMACS_INT pos)
4409 if (pos <= current_buffer->overlay_center) 4410 if (pos <= current_buffer->overlay_center)
4410 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 4411 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
4411 { 4412 {
4412 int endpos; 4413 EMACS_INT endpos;
4413 XSETMISC (overlay, tail); 4414 XSETMISC (overlay, tail);
4414 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 4415 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
4415 if (endpos < pos) 4416 if (endpos < pos)
@@ -4421,7 +4422,7 @@ evaporate_overlays (EMACS_INT pos)
4421 else 4422 else
4422 for (tail = current_buffer->overlays_after; tail; tail = tail->next) 4423 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
4423 { 4424 {
4424 int startpos; 4425 EMACS_INT startpos;
4425 XSETMISC (overlay, tail); 4426 XSETMISC (overlay, tail);
4426 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 4427 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
4427 if (startpos > pos) 4428 if (startpos > pos)
diff --git a/src/buffer.h b/src/buffer.h
index 339e7d9bb6d..3a4dd106360 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -865,7 +865,7 @@ extern int overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
865 EMACS_INT *prev_ptr, int change_req); 865 EMACS_INT *prev_ptr, int change_req);
866extern int sort_overlays (Lisp_Object *, int, struct window *); 866extern int sort_overlays (Lisp_Object *, int, struct window *);
867extern void recenter_overlay_lists (struct buffer *, EMACS_INT); 867extern void recenter_overlay_lists (struct buffer *, EMACS_INT);
868extern int overlay_strings (EMACS_INT, struct window *, unsigned char **); 868extern EMACS_INT overlay_strings (EMACS_INT, struct window *, unsigned char **);
869extern void validate_region (Lisp_Object *, Lisp_Object *); 869extern void validate_region (Lisp_Object *, Lisp_Object *);
870extern void set_buffer_internal (struct buffer *); 870extern void set_buffer_internal (struct buffer *);
871extern void set_buffer_internal_1 (struct buffer *); 871extern void set_buffer_internal_1 (struct buffer *);
diff --git a/src/callproc.c b/src/callproc.c
index 8c1384df6a1..6f70631a484 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -678,9 +678,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
678 QUIT; 678 QUIT;
679 679
680 { 680 {
681 register int nread; 681 register EMACS_INT nread;
682 int first = 1; 682 int first = 1;
683 int total_read = 0; 683 EMACS_INT total_read = 0;
684 int carryover = 0; 684 int carryover = 0;
685 int display_on_the_fly = display_p; 685 int display_on_the_fly = display_p;
686 struct coding_system saved_coding; 686 struct coding_system saved_coding;
diff --git a/src/casefiddle.c b/src/casefiddle.c
index b6551618b2f..a9169f79951 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -352,8 +352,8 @@ static Lisp_Object
352operate_on_word (Lisp_Object arg, EMACS_INT *newpoint) 352operate_on_word (Lisp_Object arg, EMACS_INT *newpoint)
353{ 353{
354 Lisp_Object val; 354 Lisp_Object val;
355 int farend; 355 EMACS_INT farend;
356 int iarg; 356 EMACS_INT iarg;
357 357
358 CHECK_NUMBER (arg); 358 CHECK_NUMBER (arg);
359 iarg = XINT (arg); 359 iarg = XINT (arg);
diff --git a/src/ccl.c b/src/ccl.c
index f418c65b01e..f98897b51fa 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -2061,10 +2061,10 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
2061 int i; 2061 int i;
2062 int outbufsize; 2062 int outbufsize;
2063 unsigned char *outbuf, *outp; 2063 unsigned char *outbuf, *outp;
2064 int str_chars, str_bytes; 2064 EMACS_INT str_chars, str_bytes;
2065#define CCL_EXECUTE_BUF_SIZE 1024 2065#define CCL_EXECUTE_BUF_SIZE 1024
2066 int source[CCL_EXECUTE_BUF_SIZE], destination[CCL_EXECUTE_BUF_SIZE]; 2066 int source[CCL_EXECUTE_BUF_SIZE], destination[CCL_EXECUTE_BUF_SIZE];
2067 int consumed_chars, consumed_bytes, produced_chars; 2067 EMACS_INT consumed_chars, consumed_bytes, produced_chars;
2068 2068
2069 if (setup_ccl_program (&ccl, ccl_prog) < 0) 2069 if (setup_ccl_program (&ccl, ccl_prog) < 0)
2070 error ("Invalid CCL program"); 2070 error ("Invalid CCL program");
@@ -2128,7 +2128,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
2128 if (outp - outbuf + MAX_MULTIBYTE_LENGTH * ccl.produced 2128 if (outp - outbuf + MAX_MULTIBYTE_LENGTH * ccl.produced
2129 > outbufsize) 2129 > outbufsize)
2130 { 2130 {
2131 int offset = outp - outbuf; 2131 EMACS_INT offset = outp - outbuf;
2132 outbufsize += MAX_MULTIBYTE_LENGTH * ccl.produced; 2132 outbufsize += MAX_MULTIBYTE_LENGTH * ccl.produced;
2133 outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); 2133 outbuf = (unsigned char *) xrealloc (outbuf, outbufsize);
2134 outp = outbuf + offset; 2134 outp = outbuf + offset;
@@ -2140,7 +2140,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
2140 { 2140 {
2141 if (outp - outbuf + ccl.produced > outbufsize) 2141 if (outp - outbuf + ccl.produced > outbufsize)
2142 { 2142 {
2143 int offset = outp - outbuf; 2143 EMACS_INT offset = outp - outbuf;
2144 outbufsize += ccl.produced; 2144 outbufsize += ccl.produced;
2145 outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); 2145 outbuf = (unsigned char *) xrealloc (outbuf, outbufsize);
2146 outp = outbuf + offset; 2146 outp = outbuf + offset;
diff --git a/src/character.c b/src/character.c
index c4a3a008bcd..d80f8139486 100644
--- a/src/character.c
+++ b/src/character.c
@@ -378,11 +378,12 @@ usage: (char-width CHAR) */)
378 characters and bytes of the substring in *NCHARS and *NBYTES 378 characters and bytes of the substring in *NCHARS and *NBYTES
379 respectively. */ 379 respectively. */
380 380
381int 381EMACS_INT
382c_string_width (const unsigned char *str, int len, int precision, int *nchars, int *nbytes) 382c_string_width (const unsigned char *str, EMACS_INT len, int precision,
383 EMACS_INT *nchars, EMACS_INT *nbytes)
383{ 384{
384 int i = 0, i_byte = 0; 385 EMACS_INT i = 0, i_byte = 0;
385 int width = 0; 386 EMACS_INT width = 0;
386 struct Lisp_Char_Table *dp = buffer_display_table (); 387 struct Lisp_Char_Table *dp = buffer_display_table ();
387 388
388 while (i_byte < len) 389 while (i_byte < len)
@@ -429,8 +430,8 @@ c_string_width (const unsigned char *str, int len, int precision, int *nchars, i
429 current buffer. The width is measured by how many columns it 430 current buffer. The width is measured by how many columns it
430 occupies on the screen. */ 431 occupies on the screen. */
431 432
432int 433EMACS_INT
433strwidth (const unsigned char *str, int len) 434strwidth (const unsigned char *str, EMACS_INT len)
434{ 435{
435 return c_string_width (str, len, -1, NULL, NULL); 436 return c_string_width (str, len, -1, NULL, NULL);
436} 437}
@@ -442,17 +443,18 @@ strwidth (const unsigned char *str, int len)
442 PRECISION, and set number of characters and bytes of the substring 443 PRECISION, and set number of characters and bytes of the substring
443 in *NCHARS and *NBYTES respectively. */ 444 in *NCHARS and *NBYTES respectively. */
444 445
445int 446EMACS_INT
446lisp_string_width (Lisp_Object string, int precision, int *nchars, int *nbytes) 447lisp_string_width (Lisp_Object string, int precision,
448 EMACS_INT *nchars, EMACS_INT *nbytes)
447{ 449{
448 int len = SCHARS (string); 450 EMACS_INT len = SCHARS (string);
449 /* This set multibyte to 0 even if STRING is multibyte when it 451 /* This set multibyte to 0 even if STRING is multibyte when it
450 contains only ascii and eight-bit-graphic, but that's 452 contains only ascii and eight-bit-graphic, but that's
451 intentional. */ 453 intentional. */
452 int multibyte = len < SBYTES (string); 454 int multibyte = len < SBYTES (string);
453 unsigned char *str = SDATA (string); 455 unsigned char *str = SDATA (string);
454 int i = 0, i_byte = 0; 456 EMACS_INT i = 0, i_byte = 0;
455 int width = 0; 457 EMACS_INT width = 0;
456 struct Lisp_Char_Table *dp = buffer_display_table (); 458 struct Lisp_Char_Table *dp = buffer_display_table ();
457 459
458 while (i < len) 460 while (i < len)
@@ -570,11 +572,11 @@ EMACS_INT
570multibyte_chars_in_text (const unsigned char *ptr, EMACS_INT nbytes) 572multibyte_chars_in_text (const unsigned char *ptr, EMACS_INT nbytes)
571{ 573{
572 const unsigned char *endp = ptr + nbytes; 574 const unsigned char *endp = ptr + nbytes;
573 int chars = 0; 575 EMACS_INT chars = 0;
574 576
575 while (ptr < endp) 577 while (ptr < endp)
576 { 578 {
577 int len = MULTIBYTE_LENGTH (ptr, endp); 579 EMACS_INT len = MULTIBYTE_LENGTH (ptr, endp);
578 580
579 if (len == 0) 581 if (len == 0)
580 abort (); 582 abort ();
@@ -592,10 +594,11 @@ multibyte_chars_in_text (const unsigned char *ptr, EMACS_INT nbytes)
592 represented by 2-byte in a multibyte text. */ 594 represented by 2-byte in a multibyte text. */
593 595
594void 596void
595parse_str_as_multibyte (const unsigned char *str, int len, int *nchars, int *nbytes) 597parse_str_as_multibyte (const unsigned char *str, EMACS_INT len,
598 EMACS_INT *nchars, EMACS_INT *nbytes)
596{ 599{
597 const unsigned char *endp = str + len; 600 const unsigned char *endp = str + len;
598 int n, chars = 0, bytes = 0; 601 EMACS_INT n, chars = 0, bytes = 0;
599 602
600 if (len >= MAX_MULTIBYTE_LENGTH) 603 if (len >= MAX_MULTIBYTE_LENGTH)
601 { 604 {
@@ -633,12 +636,13 @@ parse_str_as_multibyte (const unsigned char *str, int len, int *nchars, int *nby
633 area and that is enough. Return the number of bytes of the 636 area and that is enough. Return the number of bytes of the
634 resulting text. */ 637 resulting text. */
635 638
636int 639EMACS_INT
637str_as_multibyte (unsigned char *str, int len, int nbytes, int *nchars) 640str_as_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT nbytes,
641 EMACS_INT *nchars)
638{ 642{
639 unsigned char *p = str, *endp = str + nbytes; 643 unsigned char *p = str, *endp = str + nbytes;
640 unsigned char *to; 644 unsigned char *to;
641 int chars = 0; 645 EMACS_INT chars = 0;
642 int n; 646 int n;
643 647
644 if (nbytes >= MAX_MULTIBYTE_LENGTH) 648 if (nbytes >= MAX_MULTIBYTE_LENGTH)
@@ -709,11 +713,11 @@ str_as_multibyte (unsigned char *str, int len, int nbytes, int *nchars)
709 bytes it may ocupy when converted to multibyte string by 713 bytes it may ocupy when converted to multibyte string by
710 `str_to_multibyte'. */ 714 `str_to_multibyte'. */
711 715
712int 716EMACS_INT
713parse_str_to_multibyte (const unsigned char *str, int len) 717parse_str_to_multibyte (const unsigned char *str, EMACS_INT len)
714{ 718{
715 const unsigned char *endp = str + len; 719 const unsigned char *endp = str + len;
716 int bytes; 720 EMACS_INT bytes;
717 721
718 for (bytes = 0; str < endp; str++) 722 for (bytes = 0; str < endp; str++)
719 bytes += (*str < 0x80) ? 1 : 2; 723 bytes += (*str < 0x80) ? 1 : 2;
@@ -727,8 +731,8 @@ parse_str_to_multibyte (const unsigned char *str, int len)
727 that we can use LEN bytes at STR as a work area and that is 731 that we can use LEN bytes at STR as a work area and that is
728 enough. */ 732 enough. */
729 733
730int 734EMACS_INT
731str_to_multibyte (unsigned char *str, int len, int bytes) 735str_to_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT bytes)
732{ 736{
733 unsigned char *p = str, *endp = str + bytes; 737 unsigned char *p = str, *endp = str + bytes;
734 unsigned char *to; 738 unsigned char *to;
@@ -756,8 +760,8 @@ str_to_multibyte (unsigned char *str, int len, int bytes)
756 actually converts characters in the range 0x80..0xFF to 760 actually converts characters in the range 0x80..0xFF to
757 unibyte. */ 761 unibyte. */
758 762
759int 763EMACS_INT
760str_as_unibyte (unsigned char *str, int bytes) 764str_as_unibyte (unsigned char *str, EMACS_INT bytes)
761{ 765{
762 const unsigned char *p = str, *endp = str + bytes; 766 const unsigned char *p = str, *endp = str + bytes;
763 unsigned char *to; 767 unsigned char *to;
@@ -818,14 +822,14 @@ str_to_unibyte (const unsigned char *src, unsigned char *dst, EMACS_INT chars, i
818} 822}
819 823
820 824
821int 825EMACS_INT
822string_count_byte8 (Lisp_Object string) 826string_count_byte8 (Lisp_Object string)
823{ 827{
824 int multibyte = STRING_MULTIBYTE (string); 828 int multibyte = STRING_MULTIBYTE (string);
825 int nbytes = SBYTES (string); 829 EMACS_INT nbytes = SBYTES (string);
826 unsigned char *p = SDATA (string); 830 unsigned char *p = SDATA (string);
827 unsigned char *pend = p + nbytes; 831 unsigned char *pend = p + nbytes;
828 int count = 0; 832 EMACS_INT count = 0;
829 int c, len; 833 int c, len;
830 834
831 if (multibyte) 835 if (multibyte)
@@ -851,10 +855,10 @@ string_count_byte8 (Lisp_Object string)
851Lisp_Object 855Lisp_Object
852string_escape_byte8 (Lisp_Object string) 856string_escape_byte8 (Lisp_Object string)
853{ 857{
854 int nchars = SCHARS (string); 858 EMACS_INT nchars = SCHARS (string);
855 int nbytes = SBYTES (string); 859 EMACS_INT nbytes = SBYTES (string);
856 int multibyte = STRING_MULTIBYTE (string); 860 int multibyte = STRING_MULTIBYTE (string);
857 int byte8_count; 861 EMACS_INT byte8_count;
858 const unsigned char *src, *src_end; 862 const unsigned char *src, *src_end;
859 unsigned char *dst; 863 unsigned char *dst;
860 Lisp_Object val; 864 Lisp_Object val;
@@ -869,12 +873,22 @@ string_escape_byte8 (Lisp_Object string)
869 return string; 873 return string;
870 874
871 if (multibyte) 875 if (multibyte)
872 /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ 876 {
873 val = make_uninit_multibyte_string (nchars + byte8_count * 3, 877 if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count
874 nbytes + byte8_count * 2); 878 || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count)
879 error ("Maximum string size exceeded");
880
881 /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */
882 val = make_uninit_multibyte_string (nchars + byte8_count * 3,
883 nbytes + byte8_count * 2);
884 }
875 else 885 else
876 /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ 886 {
877 val = make_uninit_string (nbytes + byte8_count * 3); 887 if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count)
888 error ("Maximum string size exceeded");
889 /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */
890 val = make_uninit_string (nbytes + byte8_count * 3);
891 }
878 892
879 src = SDATA (string); 893 src = SDATA (string);
880 src_end = src + nbytes; 894 src_end = src + nbytes;
diff --git a/src/character.h b/src/character.h
index 8726b2ae1d6..aea1a47a1f6 100644
--- a/src/character.h
+++ b/src/character.h
@@ -603,17 +603,20 @@ extern int string_char (const unsigned char *,
603 603
604extern int translate_char (Lisp_Object, int c); 604extern int translate_char (Lisp_Object, int c);
605extern int char_printable_p (int c); 605extern int char_printable_p (int c);
606extern void parse_str_as_multibyte (const unsigned char *, int, int *, 606extern void parse_str_as_multibyte (const unsigned char *,
607 int *); 607 EMACS_INT, EMACS_INT *, EMACS_INT *);
608extern int parse_str_to_multibyte (const unsigned char *, int); 608extern EMACS_INT parse_str_to_multibyte (const unsigned char *, EMACS_INT);
609extern int str_as_multibyte (unsigned char *, int, int, int *); 609extern EMACS_INT str_as_multibyte (unsigned char *, EMACS_INT, EMACS_INT,
610extern int str_to_multibyte (unsigned char *, int, int); 610 EMACS_INT *);
611extern int str_as_unibyte (unsigned char *, int); 611extern EMACS_INT str_to_multibyte (unsigned char *, EMACS_INT, EMACS_INT);
612extern EMACS_INT str_as_unibyte (unsigned char *, EMACS_INT);
612extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *, 613extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *,
613 EMACS_INT, int); 614 EMACS_INT, int);
614extern int strwidth (const unsigned char *, int); 615extern EMACS_INT strwidth (const unsigned char *, EMACS_INT);
615extern int c_string_width (const unsigned char *, int, int, int *, int *); 616extern EMACS_INT c_string_width (const unsigned char *, EMACS_INT, int,
616extern int lisp_string_width (Lisp_Object, int, int *, int *); 617 EMACS_INT *, EMACS_INT *);
618extern EMACS_INT lisp_string_width (Lisp_Object, int,
619 EMACS_INT *, EMACS_INT *);
617 620
618extern Lisp_Object Vprintable_chars; 621extern Lisp_Object Vprintable_chars;
619 622
diff --git a/src/charset.c b/src/charset.c
index 036d7146db6..8051b11330e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -427,7 +427,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
427 427
428 428
429/* Read a hexadecimal number (preceded by "0x") from the file FP while 429/* Read a hexadecimal number (preceded by "0x") from the file FP while
430 paying attention to comment charcter '#'. */ 430 paying attention to comment character '#'. */
431 431
432static INLINE unsigned 432static INLINE unsigned
433read_hex (FILE *fp, int *eof) 433read_hex (FILE *fp, int *eof)
diff --git a/src/cmds.c b/src/cmds.c
index f12e759b7a6..e12d7c370d9 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -37,7 +37,7 @@ Lisp_Object Qkill_forward_chars, Qkill_backward_chars;
37/* A possible value for a buffer's overwrite-mode variable. */ 37/* A possible value for a buffer's overwrite-mode variable. */
38Lisp_Object Qoverwrite_mode_binary; 38Lisp_Object Qoverwrite_mode_binary;
39 39
40static int internal_self_insert (int, int); 40static int internal_self_insert (int, EMACS_INT);
41 41
42DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, 42DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
43 doc: /* Return buffer position N characters after (before if N negative) point. */) 43 doc: /* Return buffer position N characters after (before if N negative) point. */)
@@ -68,7 +68,7 @@ right or to the left on the screen. This is in contrast with
68 hooks, etcetera), that's not a good approach. So we validate the 68 hooks, etcetera), that's not a good approach. So we validate the
69 proposed position, then set point. */ 69 proposed position, then set point. */
70 { 70 {
71 int new_point = PT + XINT (n); 71 EMACS_INT new_point = PT + XINT (n);
72 72
73 if (new_point < BEGV) 73 if (new_point < BEGV)
74 { 74 {
@@ -116,9 +116,9 @@ With positive N, a non-empty line at the end counts as one line
116successfully moved (for the return value). */) 116successfully moved (for the return value). */)
117 (Lisp_Object n) 117 (Lisp_Object n)
118{ 118{
119 int opoint = PT, opoint_byte = PT_BYTE; 119 EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
120 int pos, pos_byte; 120 EMACS_INT pos, pos_byte;
121 int count, shortage; 121 EMACS_INT count, shortage;
122 122
123 if (NILP (n)) 123 if (NILP (n))
124 count = 1; 124 count = 1;
@@ -188,7 +188,7 @@ not move. To ignore field boundaries bind `inhibit-field-text-motion'
188to t. */) 188to t. */)
189 (Lisp_Object n) 189 (Lisp_Object n)
190{ 190{
191 int newpos; 191 EMACS_INT newpos;
192 192
193 if (NILP (n)) 193 if (NILP (n))
194 XSETFASTINT (n, 1); 194 XSETFASTINT (n, 1);
@@ -233,7 +233,7 @@ N was explicitly specified.
233The command `delete-forward' is preferable for interactive use. */) 233The command `delete-forward' is preferable for interactive use. */)
234 (Lisp_Object n, Lisp_Object killflag) 234 (Lisp_Object n, Lisp_Object killflag)
235{ 235{
236 int pos; 236 EMACS_INT pos;
237 237
238 CHECK_NUMBER (n); 238 CHECK_NUMBER (n);
239 239
@@ -303,7 +303,7 @@ After insertion, the value of `auto-fill-function' is called if the
303 bitch_at_user (); 303 bitch_at_user ();
304 { 304 {
305 int character = translate_char (Vtranslation_table_for_input, 305 int character = translate_char (Vtranslation_table_for_input,
306 XINT (last_command_event)); 306 (int) XINT (last_command_event));
307 int val = internal_self_insert (character, XFASTINT (n)); 307 int val = internal_self_insert (character, XFASTINT (n));
308 if (val == 2) 308 if (val == 2)
309 nonundocount = 0; 309 nonundocount = 0;
@@ -323,7 +323,7 @@ static Lisp_Object Qexpand_abbrev;
323static Lisp_Object Qpost_self_insert_hook, Vpost_self_insert_hook; 323static Lisp_Object Qpost_self_insert_hook, Vpost_self_insert_hook;
324 324
325static int 325static int
326internal_self_insert (int c, int n) 326internal_self_insert (int c, EMACS_INT n)
327{ 327{
328 int hairy = 0; 328 int hairy = 0;
329 Lisp_Object tem; 329 Lisp_Object tem;
@@ -333,8 +333,8 @@ internal_self_insert (int c, int n)
333 int len; 333 int len;
334 /* Working buffer and pointer for multi-byte form of C. */ 334 /* Working buffer and pointer for multi-byte form of C. */
335 unsigned char str[MAX_MULTIBYTE_LENGTH]; 335 unsigned char str[MAX_MULTIBYTE_LENGTH];
336 int chars_to_delete = 0; 336 EMACS_INT chars_to_delete = 0;
337 int spaces_to_insert = 0; 337 EMACS_INT spaces_to_insert = 0;
338 338
339 overwrite = current_buffer->overwrite_mode; 339 overwrite = current_buffer->overwrite_mode;
340 if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions)) 340 if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
@@ -380,12 +380,12 @@ internal_self_insert (int c, int n)
380 chars_to_delete = n; 380 chars_to_delete = n;
381 else if (c != '\n' && c2 != '\n') 381 else if (c != '\n' && c2 != '\n')
382 { 382 {
383 int pos = PT; 383 EMACS_INT pos = PT;
384 int pos_byte = PT_BYTE; 384 EMACS_INT pos_byte = PT_BYTE;
385 /* Column the cursor should be placed at after this insertion. 385 /* Column the cursor should be placed at after this insertion.
386 The correct value should be calculated only when necessary. */ 386 The correct value should be calculated only when necessary. */
387 int target_clm = ((int) current_column () /* iftc */ 387 int target_clm = ((int) current_column () /* iftc */
388 + n * XINT (Fchar_width (make_number (c)))); 388 + n * (int) XINT (Fchar_width (make_number (c))));
389 389
390 /* The actual cursor position after the trial of moving 390 /* The actual cursor position after the trial of moving
391 to column TARGET_CLM. It is greater than TARGET_CLM 391 to column TARGET_CLM. It is greater than TARGET_CLM
@@ -393,7 +393,8 @@ internal_self_insert (int c, int n)
393 character. In that case, the new point is set after 393 character. In that case, the new point is set after
394 that character. */ 394 that character. */
395 int actual_clm 395 int actual_clm
396 = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); 396 = (int) XFASTINT (Fmove_to_column (make_number (target_clm),
397 Qnil));
397 398
398 chars_to_delete = PT - pos; 399 chars_to_delete = PT - pos;
399 400
@@ -524,7 +525,7 @@ syms_of_cmds (void)
524 525
525 DEFVAR_LISP ("post-self-insert-hook", &Vpost_self_insert_hook, 526 DEFVAR_LISP ("post-self-insert-hook", &Vpost_self_insert_hook,
526 doc: /* Hook run at the end of `self-insert-command'. 527 doc: /* Hook run at the end of `self-insert-command'.
527This run is run after inserting the charater. */); 528This is run after inserting the character. */);
528 Vpost_self_insert_hook = Qnil; 529 Vpost_self_insert_hook = Qnil;
529 530
530 defsubr (&Sforward_point); 531 defsubr (&Sforward_point);
diff --git a/src/coding.c b/src/coding.c
index 6012978b60a..d6285ed9245 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -2008,7 +2008,7 @@ detect_coding_emacs_mule (struct coding_system *coding,
2008 } 2008 }
2009 else 2009 else
2010 { 2010 {
2011 int more_bytes = emacs_mule_bytes[*src_base] - 1; 2011 int more_bytes = emacs_mule_bytes[c] - 1;
2012 2012
2013 while (more_bytes > 0) 2013 while (more_bytes > 0)
2014 { 2014 {
@@ -4490,7 +4490,10 @@ encode_coding_iso_2022 (struct coding_system *coding)
4490 charset_list = CODING_ATTR_CHARSET_LIST (attrs); 4490 charset_list = CODING_ATTR_CHARSET_LIST (attrs);
4491 coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); 4491 coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs));
4492 4492
4493 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); 4493 ascii_compatible
4494 = (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))
4495 && ! (CODING_ISO_FLAGS (coding) & (CODING_ISO_FLAG_DESIGNATION
4496 | CODING_ISO_FLAG_LOCKING_SHIFT)));
4494 4497
4495 while (charbuf < charbuf_end) 4498 while (charbuf < charbuf_end)
4496 { 4499 {
diff --git a/src/commands.h b/src/commands.h
index 52136428eee..6b22da8ba15 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -74,7 +74,7 @@ extern Lisp_Object Vthis_command;
74extern Lisp_Object unread_switch_frame; 74extern Lisp_Object unread_switch_frame;
75 75
76/* The value of point when the last command was started. */ 76/* The value of point when the last command was started. */
77extern int last_point_position; 77extern EMACS_INT last_point_position;
78 78
79/* The buffer that was current when the last command was started. */ 79/* The buffer that was current when the last command was started. */
80extern Lisp_Object last_point_position_buffer; 80extern Lisp_Object last_point_position_buffer;
diff --git a/src/composite.c b/src/composite.c
index bc5a67ef6e2..be9aafbeacc 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -180,7 +180,8 @@ Lisp_Object composition_temp;
180 If the composition is invalid, return -1. */ 180 If the composition is invalid, return -1. */
181 181
182int 182int
183get_composition_id (int charpos, int bytepos, int nchars, Lisp_Object prop, Lisp_Object string) 183get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
184 Lisp_Object prop, Lisp_Object string)
184{ 185{
185 Lisp_Object id, length, components, key, *key_contents; 186 Lisp_Object id, length, components, key, *key_contents;
186 int glyph_len; 187 int glyph_len;
@@ -188,7 +189,8 @@ get_composition_id (int charpos, int bytepos, int nchars, Lisp_Object prop, Lisp
188 int hash_index; 189 int hash_index;
189 unsigned hash_code; 190 unsigned hash_code;
190 struct composition *cmp; 191 struct composition *cmp;
191 int i, ch; 192 EMACS_INT i;
193 int ch;
192 194
193 /* PROP should be 195 /* PROP should be
194 Form-A: ((LENGTH . COMPONENTS) . MODIFICATION-FUNC) 196 Form-A: ((LENGTH . COMPONENTS) . MODIFICATION-FUNC)
@@ -290,7 +292,7 @@ get_composition_id (int charpos, int bytepos, int nchars, Lisp_Object prop, Lisp
290 && VECTORP (AREF (components, 0))) 292 && VECTORP (AREF (components, 0)))
291 { 293 {
292 /* COMPONENTS is a glyph-string. */ 294 /* COMPONENTS is a glyph-string. */
293 int len = ASIZE (key); 295 EMACS_UINT len = ASIZE (key);
294 296
295 for (i = 1; i < len; i++) 297 for (i = 1; i < len; i++)
296 if (! VECTORP (AREF (key, i))) 298 if (! VECTORP (AREF (key, i)))
@@ -298,7 +300,7 @@ get_composition_id (int charpos, int bytepos, int nchars, Lisp_Object prop, Lisp
298 } 300 }
299 else if (VECTORP (components) || CONSP (components)) 301 else if (VECTORP (components) || CONSP (components))
300 { 302 {
301 int len = XVECTOR (key)->size; 303 EMACS_UINT len = XVECTOR (key)->size;
302 304
303 /* The number of elements should be odd. */ 305 /* The number of elements should be odd. */
304 if ((len % 2) == 0) 306 if ((len % 2) == 0)
@@ -427,7 +429,9 @@ get_composition_id (int charpos, int bytepos, int nchars, Lisp_Object prop, Lisp
427 This doesn't check the validity of composition. */ 429 This doesn't check the validity of composition. */
428 430
429int 431int
430find_composition (int pos, int limit, EMACS_INT *start, EMACS_INT *end, Lisp_Object *prop, Lisp_Object object) 432find_composition (EMACS_INT pos, EMACS_INT limit,
433 EMACS_INT *start, EMACS_INT *end,
434 Lisp_Object *prop, Lisp_Object object)
431{ 435{
432 Lisp_Object val; 436 Lisp_Object val;
433 437
@@ -465,7 +469,7 @@ find_composition (int pos, int limit, EMACS_INT *start, EMACS_INT *end, Lisp_Obj
465 FROM and TO with property PROP. */ 469 FROM and TO with property PROP. */
466 470
467static void 471static void
468run_composition_function (int from, int to, Lisp_Object prop) 472run_composition_function (EMACS_INT from, EMACS_INT to, Lisp_Object prop)
469{ 473{
470 Lisp_Object func; 474 Lisp_Object func;
471 EMACS_INT start, end; 475 EMACS_INT start, end;
@@ -628,7 +632,8 @@ make_composition_value_copy (Lisp_Object list)
628 indices START and END in STRING. */ 632 indices START and END in STRING. */
629 633
630void 634void
631compose_text (int start, int end, Lisp_Object components, Lisp_Object modification_func, Lisp_Object string) 635compose_text (EMACS_INT start, EMACS_INT end, Lisp_Object components,
636 Lisp_Object modification_func, Lisp_Object string)
632{ 637{
633 Lisp_Object prop; 638 Lisp_Object prop;
634 639
@@ -735,7 +740,8 @@ composition_gstring_p (Lisp_Object gstring)
735} 740}
736 741
737int 742int
738composition_gstring_width (Lisp_Object gstring, int from, int to, struct font_metrics *metrics) 743composition_gstring_width (Lisp_Object gstring, EMACS_INT from, EMACS_INT to,
744 struct font_metrics *metrics)
739{ 745{
740 Lisp_Object *glyph; 746 Lisp_Object *glyph;
741 int width = 0; 747 int width = 0;
@@ -907,7 +913,7 @@ autocmp_chars (Lisp_Object rule, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT
907 EMACS_INT to; 913 EMACS_INT to;
908 EMACS_INT pt = PT, pt_byte = PT_BYTE; 914 EMACS_INT pt = PT, pt_byte = PT_BYTE;
909 Lisp_Object re, font_object, lgstring; 915 Lisp_Object re, font_object, lgstring;
910 int len; 916 EMACS_INT len;
911 917
912 record_unwind_save_match_data (); 918 record_unwind_save_match_data ();
913 re = AREF (rule, 0); 919 re = AREF (rule, 0);
@@ -1397,7 +1403,7 @@ composition_update_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_I
1397 /* automatic composition */ 1403 /* automatic composition */
1398 Lisp_Object gstring = composition_gstring_from_id (cmp_it->id); 1404 Lisp_Object gstring = composition_gstring_from_id (cmp_it->id);
1399 Lisp_Object glyph; 1405 Lisp_Object glyph;
1400 int from, to; 1406 EMACS_INT from;
1401 1407
1402 if (cmp_it->nglyphs == 0) 1408 if (cmp_it->nglyphs == 0)
1403 { 1409 {
@@ -1656,7 +1662,7 @@ find_automatic_composition (EMACS_INT pos, EMACS_INT limit, EMACS_INT *start, EM
1656/* Return the adjusted point provided that point is moved from LAST_PT 1662/* Return the adjusted point provided that point is moved from LAST_PT
1657 to NEW_PT. */ 1663 to NEW_PT. */
1658 1664
1659int 1665EMACS_INT
1660composition_adjust_point (EMACS_INT last_pt, EMACS_INT new_pt) 1666composition_adjust_point (EMACS_INT last_pt, EMACS_INT new_pt)
1661{ 1667{
1662 EMACS_INT charpos, bytepos, startpos, beg, end, pos; 1668 EMACS_INT charpos, bytepos, startpos, beg, end, pos;
@@ -1879,9 +1885,9 @@ See `find-composition' for more details. */)
1879 id = COMPOSITION_ID (prop); 1885 id = COMPOSITION_ID (prop);
1880 else 1886 else
1881 { 1887 {
1882 int start_byte = (NILP (string) 1888 EMACS_INT start_byte = (NILP (string)
1883 ? CHAR_TO_BYTE (start) 1889 ? CHAR_TO_BYTE (start)
1884 : string_char_to_byte (string, start)); 1890 : string_char_to_byte (string, start));
1885 id = get_composition_id (start, start_byte, end - start, prop, string); 1891 id = get_composition_id (start, start_byte, end - start, prop, string);
1886 } 1892 }
1887 1893
diff --git a/src/composite.h b/src/composite.h
index 554ab554115..5c8ade39596 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -212,15 +212,16 @@ extern Lisp_Object Vauto_composition_function;
212extern Lisp_Object Qauto_composition_function; 212extern Lisp_Object Qauto_composition_function;
213extern Lisp_Object Vcomposition_function_table; 213extern Lisp_Object Vcomposition_function_table;
214 214
215extern int get_composition_id (int, int, int, Lisp_Object, Lisp_Object); 215extern int get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT,
216extern int find_composition (int, int, EMACS_INT *, EMACS_INT *, Lisp_Object *, 216 Lisp_Object, Lisp_Object);
217 Lisp_Object); 217extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *,
218 Lisp_Object *, Lisp_Object);
218extern void update_compositions (EMACS_INT, EMACS_INT, int); 219extern void update_compositions (EMACS_INT, EMACS_INT, int);
219extern void make_composition_value_copy (Lisp_Object); 220extern void make_composition_value_copy (Lisp_Object);
220extern void compose_region (int, int, Lisp_Object, Lisp_Object, 221extern void compose_region (int, int, Lisp_Object, Lisp_Object,
221 Lisp_Object); 222 Lisp_Object);
222extern void syms_of_composite (void); 223extern void syms_of_composite (void);
223extern void compose_text (int, int, Lisp_Object, Lisp_Object, 224extern void compose_text (EMACS_INT, EMACS_INT, Lisp_Object, Lisp_Object,
224 Lisp_Object); 225 Lisp_Object);
225 226
226/* Macros for lispy glyph-string. This is completely different from 227/* Macros for lispy glyph-string. This is completely different from
@@ -306,7 +307,7 @@ struct font_metrics;
306extern Lisp_Object composition_gstring_put_cache (Lisp_Object, int); 307extern Lisp_Object composition_gstring_put_cache (Lisp_Object, int);
307extern Lisp_Object composition_gstring_from_id (int); 308extern Lisp_Object composition_gstring_from_id (int);
308extern int composition_gstring_p (Lisp_Object); 309extern int composition_gstring_p (Lisp_Object);
309extern int composition_gstring_width (Lisp_Object, int, int, 310extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT,
310 struct font_metrics *); 311 struct font_metrics *);
311 312
312extern void composition_compute_stop_pos (struct composition_it *, 313extern void composition_compute_stop_pos (struct composition_it *,
@@ -319,7 +320,7 @@ extern int composition_reseat_it (struct composition_it *,
319extern int composition_update_it (struct composition_it *, 320extern int composition_update_it (struct composition_it *,
320 EMACS_INT, EMACS_INT, Lisp_Object); 321 EMACS_INT, EMACS_INT, Lisp_Object);
321 322
322extern int composition_adjust_point (EMACS_INT, EMACS_INT); 323extern EMACS_INT composition_adjust_point (EMACS_INT, EMACS_INT);
323 324
324EXFUN (Fcompose_region_internal, 4); 325EXFUN (Fcompose_region_internal, 4);
325EXFUN (Fcompose_string_internal, 5); 326EXFUN (Fcompose_string_internal, 5);
diff --git a/src/config.in b/src/config.in
index 199afbd78ba..43ebb756215 100644
--- a/src/config.in
+++ b/src/config.in
@@ -255,6 +255,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
255/* Define to 1 if you have a gif (or ungif) library. */ 255/* Define to 1 if you have a gif (or ungif) library. */
256#undef HAVE_GIF 256#undef HAVE_GIF
257 257
258/* Define if we have the GNU TLS library. */
259#undef HAVE_GNUTLS
260
258/* Define to 1 if you have the gpm library (-lgpm). */ 261/* Define to 1 if you have the gpm library (-lgpm). */
259#undef HAVE_GPM 262#undef HAVE_GPM
260 263
@@ -1094,6 +1097,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1094#include config_opsysfile 1097#include config_opsysfile
1095#include config_machfile 1098#include config_machfile
1096 1099
1100#if HAVE_GNUTLS
1101#define LIBGNUTLS $(LIBGNUTLS_LIBS)
1102#else /* not HAVE_GNUTLS */
1103#define LIBGNUTLS
1104#endif /* not HAVE_GNUTLS */
1105
1097/* Set up some defines, C and LD flags for NeXTstep interface on GNUstep. 1106/* Set up some defines, C and LD flags for NeXTstep interface on GNUstep.
1098 (There is probably a better place to do this, but right now the Cocoa 1107 (There is probably a better place to do this, but right now the Cocoa
1099 side does this in s/darwin.h and we cannot 1108 side does this in s/darwin.h and we cannot
diff --git a/src/data.c b/src/data.c
index 9490b7ac79a..78ccb75ca89 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2092,13 +2092,14 @@ ARRAY may be a vector, a string, a char-table, a bool-vector,
2092or a byte-code object. IDX starts at 0. */) 2092or a byte-code object. IDX starts at 0. */)
2093 (register Lisp_Object array, Lisp_Object idx) 2093 (register Lisp_Object array, Lisp_Object idx)
2094{ 2094{
2095 register int idxval; 2095 register EMACS_INT idxval;
2096 2096
2097 CHECK_NUMBER (idx); 2097 CHECK_NUMBER (idx);
2098 idxval = XINT (idx); 2098 idxval = XINT (idx);
2099 if (STRINGP (array)) 2099 if (STRINGP (array))
2100 { 2100 {
2101 int c, idxval_byte; 2101 int c;
2102 EMACS_INT idxval_byte;
2102 2103
2103 if (idxval < 0 || idxval >= SCHARS (array)) 2104 if (idxval < 0 || idxval >= SCHARS (array))
2104 args_out_of_range (array, idx); 2105 args_out_of_range (array, idx);
@@ -2146,7 +2147,7 @@ Return NEWELT. ARRAY may be a vector, a string, a char-table or a
2146bool-vector. IDX starts at 0. */) 2147bool-vector. IDX starts at 0. */)
2147 (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt) 2148 (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt)
2148{ 2149{
2149 register int idxval; 2150 register EMACS_INT idxval;
2150 2151
2151 CHECK_NUMBER (idx); 2152 CHECK_NUMBER (idx);
2152 idxval = XINT (idx); 2153 idxval = XINT (idx);
@@ -2181,7 +2182,7 @@ bool-vector. IDX starts at 0. */)
2181 } 2182 }
2182 else if (STRING_MULTIBYTE (array)) 2183 else if (STRING_MULTIBYTE (array))
2183 { 2184 {
2184 int idxval_byte, prev_bytes, new_bytes, nbytes; 2185 EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes;
2185 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; 2186 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;
2186 2187
2187 if (idxval < 0 || idxval >= SCHARS (array)) 2188 if (idxval < 0 || idxval >= SCHARS (array))
@@ -2197,7 +2198,7 @@ bool-vector. IDX starts at 0. */)
2197 if (prev_bytes != new_bytes) 2198 if (prev_bytes != new_bytes)
2198 { 2199 {
2199 /* We must relocate the string data. */ 2200 /* We must relocate the string data. */
2200 int nchars = SCHARS (array); 2201 EMACS_INT nchars = SCHARS (array);
2201 unsigned char *str; 2202 unsigned char *str;
2202 USE_SAFE_ALLOCA; 2203 USE_SAFE_ALLOCA;
2203 2204
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 3b6f0e543bb..ffa02e8e9c9 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#include "frame.h" 27#include "frame.h"
28#include "termhooks.h" 28#include "termhooks.h"
29#include "keyboard.h" 29#include "keyboard.h"
30#include "process.h"
30 31
31 32
32/* Subroutines. */ 33/* Subroutines. */
@@ -799,71 +800,84 @@ xd_initialize (Lisp_Object bus, int raise_error)
799 return connection; 800 return connection;
800} 801}
801 802
802 803/* Return the file descriptor for WATCH, -1 if not found. */
803/* Add connection file descriptor to input_wait_mask, in order to 804static int
804 let select() detect, whether a new message has been arrived. */ 805xd_find_watch_fd (DBusWatch *watch)
805dbus_bool_t
806xd_add_watch (DBusWatch *watch, void *data)
807{ 806{
808 /* We check only for incoming data. */
809 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE)
810 {
811#if HAVE_DBUS_WATCH_GET_UNIX_FD 807#if HAVE_DBUS_WATCH_GET_UNIX_FD
812 /* TODO: Reverse these on Win32, which prefers the opposite. */ 808 /* TODO: Reverse these on Win32, which prefers the opposite. */
813 int fd = dbus_watch_get_unix_fd(watch); 809 int fd = dbus_watch_get_unix_fd (watch);
814 if (fd == -1) 810 if (fd == -1)
815 fd = dbus_watch_get_socket(watch); 811 fd = dbus_watch_get_socket (watch);
816#else 812#else
817 int fd = dbus_watch_get_fd(watch); 813 int fd = dbus_watch_get_fd (watch);
818#endif 814#endif
819 XD_DEBUG_MESSAGE ("fd %d", fd); 815 return fd;
816}
820 817
821 if (fd == -1) 818/* Prototype. */
822 return FALSE; 819static void
820xd_read_queued_messages (int fd, void *data, int for_read);
823 821
824 /* Add the file descriptor to input_wait_mask. */ 822/* Start monitoring WATCH for possible I/O. */
825 add_keyboard_wait_descriptor (fd); 823static dbus_bool_t
826 } 824xd_add_watch (DBusWatch *watch, void *data)
825{
826 unsigned int flags = dbus_watch_get_flags (watch);
827 int fd = xd_find_watch_fd (watch);
827 828
828 /* Return. */ 829 XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d",
830 fd, flags & DBUS_WATCH_WRITABLE,
831 dbus_watch_get_enabled (watch));
832
833 if (fd == -1)
834 return FALSE;
835
836 if (dbus_watch_get_enabled (watch))
837 {
838 if (flags & DBUS_WATCH_WRITABLE)
839 add_write_fd (fd, xd_read_queued_messages, data);
840 if (flags & DBUS_WATCH_READABLE)
841 add_read_fd (fd, xd_read_queued_messages, data);
842 }
829 return TRUE; 843 return TRUE;
830} 844}
831 845
832/* Remove connection file descriptor from input_wait_mask. DATA is 846/* Stop monitoring WATCH for possible I/O.
833 the used bus, either a string or QCdbus_system_bus or 847 DATA is the used bus, either a string or QCdbus_system_bus or
834 QCdbus_session_bus. */ 848 QCdbus_session_bus. */
835void 849static void
836xd_remove_watch (DBusWatch *watch, void *data) 850xd_remove_watch (DBusWatch *watch, void *data)
837{ 851{
838 /* We check only for incoming data. */ 852 unsigned int flags = dbus_watch_get_flags (watch);
839 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 853 int fd = xd_find_watch_fd (watch);
840 {
841#if HAVE_DBUS_WATCH_GET_UNIX_FD
842 /* TODO: Reverse these on Win32, which prefers the opposite. */
843 int fd = dbus_watch_get_unix_fd(watch);
844 if (fd == -1)
845 fd = dbus_watch_get_socket(watch);
846#else
847 int fd = dbus_watch_get_fd(watch);
848#endif
849 XD_DEBUG_MESSAGE ("fd %d", fd);
850 854
851 if (fd == -1) 855 XD_DEBUG_MESSAGE ("fd %d", fd);
852 return;
853 856
854 /* Unset session environment. */ 857 if (fd == -1)
855 if ((data != NULL) && (data == (void*) XHASH (QCdbus_session_bus))) 858 return;
856 {
857 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
858 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
859 }
860 859
861 /* Remove the file descriptor from input_wait_mask. */ 860 /* Unset session environment. */
862 delete_keyboard_wait_descriptor (fd); 861 if (data != NULL && data == (void*) XHASH (QCdbus_session_bus))
862 {
863 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
864 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
863 } 865 }
864 866
865 /* Return. */ 867 if (flags & DBUS_WATCH_WRITABLE)
866 return; 868 delete_write_fd (fd);
869 if (flags & DBUS_WATCH_READABLE)
870 delete_read_fd (fd);
871}
872
873/* Toggle monitoring WATCH for possible I/O. */
874static void
875xd_toggle_watch (DBusWatch *watch, void *data)
876{
877 if (dbus_watch_get_enabled (watch))
878 xd_add_watch (watch, data);
879 else
880 xd_remove_watch (watch, data);
867} 881}
868 882
869DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, 883DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
@@ -880,7 +894,8 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
880 if (!dbus_connection_set_watch_functions (connection, 894 if (!dbus_connection_set_watch_functions (connection,
881 xd_add_watch, 895 xd_add_watch,
882 xd_remove_watch, 896 xd_remove_watch,
883 NULL, (void*) XHASH (bus), NULL)) 897 xd_toggle_watch,
898 (void*) XHASH (bus), NULL))
884 XD_SIGNAL1 (build_string ("Cannot add watch functions")); 899 XD_SIGNAL1 (build_string ("Cannot add watch functions"));
885 900
886 /* Add bus to list of registered buses. */ 901 /* Add bus to list of registered buses. */
@@ -1288,9 +1303,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE
1288 result = Qnil; 1303 result = Qnil;
1289 } 1304 }
1290 1305
1291 /* Flush connection to ensure the message is handled. */
1292 dbus_connection_flush (connection);
1293
1294 XD_DEBUG_MESSAGE ("Message sent"); 1306 XD_DEBUG_MESSAGE ("Message sent");
1295 1307
1296 /* Cleanup. */ 1308 /* Cleanup. */
@@ -1379,9 +1391,6 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */)
1379 if (!dbus_connection_send (connection, dmessage, NULL)) 1391 if (!dbus_connection_send (connection, dmessage, NULL))
1380 XD_SIGNAL1 (build_string ("Cannot send message")); 1392 XD_SIGNAL1 (build_string ("Cannot send message"));
1381 1393
1382 /* Flush connection to ensure the message is handled. */
1383 dbus_connection_flush (connection);
1384
1385 XD_DEBUG_MESSAGE ("Message sent"); 1394 XD_DEBUG_MESSAGE ("Message sent");
1386 1395
1387 /* Cleanup. */ 1396 /* Cleanup. */
@@ -1471,9 +1480,6 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */)
1471 if (!dbus_connection_send (connection, dmessage, NULL)) 1480 if (!dbus_connection_send (connection, dmessage, NULL))
1472 XD_SIGNAL1 (build_string ("Cannot send message")); 1481 XD_SIGNAL1 (build_string ("Cannot send message"));
1473 1482
1474 /* Flush connection to ensure the message is handled. */
1475 dbus_connection_flush (connection);
1476
1477 XD_DEBUG_MESSAGE ("Message sent"); 1483 XD_DEBUG_MESSAGE ("Message sent");
1478 1484
1479 /* Cleanup. */ 1485 /* Cleanup. */
@@ -1589,9 +1595,6 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
1589 if (!dbus_connection_send (connection, dmessage, NULL)) 1595 if (!dbus_connection_send (connection, dmessage, NULL))
1590 XD_SIGNAL1 (build_string ("Cannot send message")); 1596 XD_SIGNAL1 (build_string ("Cannot send message"));
1591 1597
1592 /* Flush connection to ensure the message is handled. */
1593 dbus_connection_flush (connection);
1594
1595 XD_DEBUG_MESSAGE ("Signal sent"); 1598 XD_DEBUG_MESSAGE ("Signal sent");
1596 1599
1597 /* Cleanup. */ 1600 /* Cleanup. */
@@ -1601,76 +1604,26 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
1601 return Qt; 1604 return Qt;
1602} 1605}
1603 1606
1604/* Check, whether there is pending input in the message queue of the 1607/* Read one queued incoming message of the D-Bus BUS.
1605 D-Bus BUS. BUS is either a Lisp symbol, :system or :session, or a 1608 BUS is either a Lisp symbol, :system or :session, or a string denoting
1606 string denoting the bus address. */ 1609 the bus address. */
1607int 1610static void
1608xd_get_dispatch_status (Lisp_Object bus) 1611xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
1609{
1610 DBusConnection *connection;
1611
1612 /* Open a connection to the bus. */
1613 connection = xd_initialize (bus, FALSE);
1614 if (connection == NULL) return FALSE;
1615
1616 /* Non blocking read of the next available message. */
1617 dbus_connection_read_write (connection, 0);
1618
1619 /* Return. */
1620 return
1621 (dbus_connection_get_dispatch_status (connection)
1622 == DBUS_DISPATCH_DATA_REMAINS)
1623 ? TRUE : FALSE;
1624}
1625
1626/* Check for queued incoming messages from the buses. */
1627int
1628xd_pending_messages (void)
1629{
1630 Lisp_Object busp = Vdbus_registered_buses;
1631
1632 while (!NILP (busp))
1633 {
1634 /* We do not want to have an autolaunch for the session bus. */
1635 if (EQ ((CAR_SAFE (busp)), QCdbus_session_bus)
1636 && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL)
1637 continue;
1638
1639 if (xd_get_dispatch_status (CAR_SAFE (busp)))
1640 return TRUE;
1641
1642 busp = CDR_SAFE (busp);
1643 }
1644
1645 return FALSE;
1646}
1647
1648/* Read queued incoming message of the D-Bus BUS. BUS is either a
1649 Lisp symbol, :system or :session, or a string denoting the bus
1650 address. */
1651static Lisp_Object
1652xd_read_message (Lisp_Object bus)
1653{ 1612{
1654 Lisp_Object args, key, value; 1613 Lisp_Object args, key, value;
1655 struct gcpro gcpro1; 1614 struct gcpro gcpro1;
1656 struct input_event event; 1615 struct input_event event;
1657 DBusConnection *connection;
1658 DBusMessage *dmessage; 1616 DBusMessage *dmessage;
1659 DBusMessageIter iter; 1617 DBusMessageIter iter;
1660 unsigned int dtype; 1618 unsigned int dtype;
1661 int mtype, serial; 1619 int mtype, serial;
1662 const char *uname, *path, *interface, *member; 1620 const char *uname, *path, *interface, *member;
1663 1621
1664 /* Open a connection to the bus. */
1665 connection = xd_initialize (bus, TRUE);
1666
1667 /* Non blocking read of the next available message. */
1668 dbus_connection_read_write (connection, 0);
1669 dmessage = dbus_connection_pop_message (connection); 1622 dmessage = dbus_connection_pop_message (connection);
1670 1623
1671 /* Return if there is no queued message. */ 1624 /* Return if there is no queued message. */
1672 if (dmessage == NULL) 1625 if (dmessage == NULL)
1673 return Qnil; 1626 return;
1674 1627
1675 /* Collect the parameters. */ 1628 /* Collect the parameters. */
1676 args = Qnil; 1629 args = Qnil;
@@ -1801,22 +1754,49 @@ xd_read_message (Lisp_Object bus)
1801 cleanup: 1754 cleanup:
1802 dbus_message_unref (dmessage); 1755 dbus_message_unref (dmessage);
1803 1756
1804 RETURN_UNGCPRO (Qnil); 1757 UNGCPRO;
1805} 1758}
1806 1759
1807/* Read queued incoming messages from all buses. */ 1760/* Read queued incoming messages of the D-Bus BUS.
1808void 1761 BUS is either a Lisp symbol, :system or :session, or a string denoting
1809xd_read_queued_messages (void) 1762 the bus address. */
1763static Lisp_Object
1764xd_read_message (Lisp_Object bus)
1765{
1766 /* Open a connection to the bus. */
1767 DBusConnection *connection = xd_initialize (bus, TRUE);
1768
1769 /* Non blocking read of the next available message. */
1770 dbus_connection_read_write (connection, 0);
1771
1772 while (dbus_connection_get_dispatch_status (connection)
1773 != DBUS_DISPATCH_COMPLETE)
1774 xd_read_message_1 (connection, bus);
1775 return Qnil;
1776}
1777
1778/* Callback called when something is ready to read or write. */
1779static void
1780xd_read_queued_messages (int fd, void *data, int for_read)
1810{ 1781{
1811 Lisp_Object busp = Vdbus_registered_buses; 1782 Lisp_Object busp = Vdbus_registered_buses;
1783 Lisp_Object bus = Qnil;
1784
1785 /* Find bus related to fd. */
1786 if (data != NULL)
1787 while (!NILP (busp))
1788 {
1789 if (data == (void*) XHASH (CAR_SAFE (busp)))
1790 bus = CAR_SAFE (busp);
1791 busp = CDR_SAFE (busp);
1792 }
1793
1794 if (NILP(bus))
1795 return;
1812 1796
1797 /* We ignore all Lisp errors during the call. */
1813 xd_in_read_queued_messages = 1; 1798 xd_in_read_queued_messages = 1;
1814 while (!NILP (busp)) 1799 internal_catch (Qdbus_error, xd_read_message, bus);
1815 {
1816 /* We ignore all Lisp errors during the call. */
1817 internal_catch (Qdbus_error, xd_read_message, CAR_SAFE (busp));
1818 busp = CDR_SAFE (busp);
1819 }
1820 xd_in_read_queued_messages = 0; 1800 xd_in_read_queued_messages = 0;
1821} 1801}
1822 1802
@@ -2181,8 +2161,12 @@ be called when the D-Bus reply message arrives. */);
2181 doc: /* If non-nil, debug messages of D-Bus bindings are raised. */); 2161 doc: /* If non-nil, debug messages of D-Bus bindings are raised. */);
2182#ifdef DBUS_DEBUG 2162#ifdef DBUS_DEBUG
2183 Vdbus_debug = Qt; 2163 Vdbus_debug = Qt;
2164 /* We can also set environment DBUS_VERBOSE=1 in order to see more
2165 traces. */
2184#else 2166#else
2185 Vdbus_debug = Qnil; 2167 Vdbus_debug = Qnil;
2168 /* We do not want to abort. */
2169 setenv ("DBUS_FATAL_WARNINGS", "0", 1);
2186#endif 2170#endif
2187 2171
2188 Fprovide (intern_c_string ("dbusbind"), Qnil); 2172 Fprovide (intern_c_string ("dbusbind"), Qnil);
diff --git a/src/deps.mk b/src/deps.mk
index d00be96744b..eebf98ec003 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -230,6 +230,7 @@ xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \
230 charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \ 230 charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \
231 systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \ 231 systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \
232 keymap.h sysselect.h 232 keymap.h sysselect.h
233xml.o: xml.c buffer.h lisp.h $(config_h)
233xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \ 234xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \
234 dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \ 235 dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \
235 keyboard.h emacs-icon.h character.h charset.h ccl.h fontset.h composite.h \ 236 keyboard.h emacs-icon.h character.h charset.h ccl.h fontset.h composite.h \
diff --git a/src/dispextern.h b/src/dispextern.h
index 5138958b6db..20e074d2393 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -394,7 +394,15 @@ struct glyph
394 w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */ 394 w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */
395 unsigned font_type : 3; 395 unsigned font_type : 3;
396 396
397 struct glyph_slice slice; 397 /* A union of sub-structures for different glyph types. */
398 union
399 {
400 /* Metrics of a partial glyph of an image (type == IMAGE_GLYPH). */
401 struct glyph_slice img;
402 /* Start and end indices of glyphs of a graphme cluster of a
403 composition (type == COMPOSITE_GLYPH). */
404 struct { int from, to; } cmp;
405 } slice;
398 406
399 /* A union of sub-structures for different glyph types. */ 407 /* A union of sub-structures for different glyph types. */
400 union 408 union
@@ -402,16 +410,13 @@ struct glyph
402 /* Character code for character glyphs (type == CHAR_GLYPH). */ 410 /* Character code for character glyphs (type == CHAR_GLYPH). */
403 unsigned ch; 411 unsigned ch;
404 412
405 /* Sub-structures for type == COMPOSITION_GLYPH. */ 413 /* Sub-structures for type == COMPOSITE_GLYPH. */
406 struct 414 struct
407 { 415 {
408 /* Flag to tell if the composition is automatic or not. */ 416 /* Flag to tell if the composition is automatic or not. */
409 unsigned automatic : 1; 417 unsigned automatic : 1;
410 /* ID of the composition. */ 418 /* ID of the composition. */
411 unsigned id : 23; 419 unsigned id : 31;
412 /* Start and end indices of glyphs of the composition. */
413 unsigned from : 4;
414 unsigned to : 4;
415 } cmp; 420 } cmp;
416 421
417 /* Image ID for image glyphs (type == IMAGE_GLYPH). */ 422 /* Image ID for image glyphs (type == IMAGE_GLYPH). */
@@ -443,13 +448,21 @@ struct glyph
443#define CHAR_GLYPH_SPACE_P(GLYPH) \ 448#define CHAR_GLYPH_SPACE_P(GLYPH) \
444 ((GLYPH).u.ch == SPACEGLYPH && (GLYPH).face_id == DEFAULT_FACE_ID) 449 ((GLYPH).u.ch == SPACEGLYPH && (GLYPH).face_id == DEFAULT_FACE_ID)
445 450
446/* Are glyph slices of glyphs *X and *Y equal */ 451/* Are glyph slices of glyphs *X and *Y equal? It assumes that both
452 glyphs have the same type.
453
454 Note: for composition glyphs, we don't have to compare slice.cmp.to
455 because they should be the same if and only if slice.cmp.from are
456 the same. */
447 457
448#define GLYPH_SLICE_EQUAL_P(X, Y) \ 458#define GLYPH_SLICE_EQUAL_P(X, Y) \
449 ((X)->slice.x == (Y)->slice.x \ 459 ((X)->type == IMAGE_GLYPH \
450 && (X)->slice.y == (Y)->slice.y \ 460 ? ((X)->slice.img.x == (Y)->slice.img.x \
451 && (X)->slice.width == (Y)->slice.width \ 461 && (X)->slice.img.y == (Y)->slice.img.y \
452 && (X)->slice.height == (Y)->slice.height) 462 && (X)->slice.img.width == (Y)->slice.img.width \
463 && (X)->slice.img.height == (Y)->slice.img.height) \
464 : ((X)->type != COMPOSITE_GLYPH \
465 || (X)->slice.cmp.from == (Y)->slice.cmp.from))
453 466
454/* Are glyphs *X and *Y displayed equal? */ 467/* Are glyphs *X and *Y displayed equal? */
455 468
@@ -1770,7 +1783,7 @@ typedef enum { NEUTRAL_DIR, L2R, R2L } bidi_dir_t;
1770/* Data type for storing information about characters we need to 1783/* Data type for storing information about characters we need to
1771 remember. */ 1784 remember. */
1772struct bidi_saved_info { 1785struct bidi_saved_info {
1773 int bytepos, charpos; /* character's buffer position */ 1786 EMACS_INT bytepos, charpos; /* character's buffer position */
1774 bidi_type_t type; /* character's resolved bidi type */ 1787 bidi_type_t type; /* character's resolved bidi type */
1775 bidi_type_t type_after_w1; /* original type of the character, after W1 */ 1788 bidi_type_t type_after_w1; /* original type of the character, after W1 */
1776 bidi_type_t orig_type; /* type as we found it in the buffer */ 1789 bidi_type_t orig_type; /* type as we found it in the buffer */
@@ -2054,7 +2067,7 @@ struct it
2054 2067
2055 /* Number of characters in the string (s, or it->string) we iterate 2068 /* Number of characters in the string (s, or it->string) we iterate
2056 over. */ 2069 over. */
2057 int string_nchars; 2070 EMACS_INT string_nchars;
2058 2071
2059 /* Start and end of a visible region; -1 if the region is not 2072 /* Start and end of a visible region; -1 if the region is not
2060 visible in the window. */ 2073 visible in the window. */
@@ -2896,12 +2909,12 @@ extern EMACS_INT tool_bar_button_relief;
2896 2909
2897extern void bidi_init_it (EMACS_INT, EMACS_INT, struct bidi_it *); 2910extern void bidi_init_it (EMACS_INT, EMACS_INT, struct bidi_it *);
2898extern void bidi_move_to_visually_next (struct bidi_it *); 2911extern void bidi_move_to_visually_next (struct bidi_it *);
2899extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *); 2912extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, int);
2900extern int bidi_mirror_char (int); 2913extern int bidi_mirror_char (int);
2901 2914
2902/* Defined in xdisp.c */ 2915/* Defined in xdisp.c */
2903 2916
2904struct glyph_row *row_containing_pos (struct window *, int, 2917struct glyph_row *row_containing_pos (struct window *, EMACS_INT,
2905 struct glyph_row *, 2918 struct glyph_row *,
2906 struct glyph_row *, int); 2919 struct glyph_row *, int);
2907EMACS_INT string_buffer_position (struct window *, Lisp_Object, 2920EMACS_INT string_buffer_position (struct window *, Lisp_Object,
@@ -2929,7 +2942,8 @@ void remember_mouse_glyph (struct frame *, int, int, NativeRectangle *);
2929void mark_window_display_accurate (Lisp_Object, int); 2942void mark_window_display_accurate (Lisp_Object, int);
2930void redisplay_preserve_echo_area (int); 2943void redisplay_preserve_echo_area (int);
2931int set_cursor_from_row (struct window *, struct glyph_row *, 2944int set_cursor_from_row (struct window *, struct glyph_row *,
2932 struct glyph_matrix *, int, int, int, int); 2945 struct glyph_matrix *, EMACS_INT, EMACS_INT,
2946 int, int);
2933void init_iterator (struct it *, struct window *, EMACS_INT, 2947void init_iterator (struct it *, struct window *, EMACS_INT,
2934 EMACS_INT, struct glyph_row *, enum face_id); 2948 EMACS_INT, struct glyph_row *, enum face_id);
2935void init_iterator_to_row_start (struct it *, struct window *, 2949void init_iterator_to_row_start (struct it *, struct window *,
@@ -2937,7 +2951,7 @@ void init_iterator_to_row_start (struct it *, struct window *,
2937int get_next_display_element (struct it *); 2951int get_next_display_element (struct it *);
2938void set_iterator_to_next (struct it *, int); 2952void set_iterator_to_next (struct it *, int);
2939void start_display (struct it *, struct window *, struct text_pos); 2953void start_display (struct it *, struct window *, struct text_pos);
2940void move_it_to (struct it *, int, int, int, int, int); 2954void move_it_to (struct it *, EMACS_INT, int, int, int, int);
2941void move_it_vertically (struct it *, int); 2955void move_it_vertically (struct it *, int);
2942void move_it_vertically_backward (struct it *, int); 2956void move_it_vertically_backward (struct it *, int);
2943void move_it_by_lines (struct it *, int, int); 2957void move_it_by_lines (struct it *, int, int);
@@ -2956,7 +2970,7 @@ extern int help_echo_showing_p;
2956extern int current_mode_line_height, current_header_line_height; 2970extern int current_mode_line_height, current_header_line_height;
2957extern Lisp_Object help_echo_string, help_echo_window; 2971extern Lisp_Object help_echo_string, help_echo_window;
2958extern Lisp_Object help_echo_object, previous_help_echo_string; 2972extern Lisp_Object help_echo_object, previous_help_echo_string;
2959extern int help_echo_pos; 2973extern EMACS_INT help_echo_pos;
2960extern struct frame *last_mouse_frame; 2974extern struct frame *last_mouse_frame;
2961extern int last_tool_bar_item; 2975extern int last_tool_bar_item;
2962extern Lisp_Object Vmouse_autoselect_window; 2976extern Lisp_Object Vmouse_autoselect_window;
@@ -3209,11 +3223,11 @@ extern Lisp_Object buffer_posn_from_coords (struct window *,
3209 Lisp_Object *, 3223 Lisp_Object *,
3210 int *, int *, int *, int *); 3224 int *, int *, int *, int *);
3211extern Lisp_Object mode_line_string (struct window *, enum window_part, 3225extern Lisp_Object mode_line_string (struct window *, enum window_part,
3212 int *, int *, int *, 3226 int *, int *, EMACS_INT *,
3213 Lisp_Object *, 3227 Lisp_Object *,
3214 int *, int *, int *, int *); 3228 int *, int *, int *, int *);
3215extern Lisp_Object marginal_area_string (struct window *, enum window_part, 3229extern Lisp_Object marginal_area_string (struct window *, enum window_part,
3216 int *, int *, int *, 3230 int *, int *, EMACS_INT *,
3217 Lisp_Object *, 3231 Lisp_Object *,
3218 int *, int *, int *, int *); 3232 int *, int *, int *, int *);
3219extern void redraw_frame (struct frame *); 3233extern void redraw_frame (struct frame *);
@@ -3236,9 +3250,9 @@ void shift_glyph_matrix (struct window *, struct glyph_matrix *,
3236 int, int, int); 3250 int, int, int);
3237void rotate_matrix (struct glyph_matrix *, int, int, int); 3251void rotate_matrix (struct glyph_matrix *, int, int, int);
3238void increment_matrix_positions (struct glyph_matrix *, 3252void increment_matrix_positions (struct glyph_matrix *,
3239 int, int, int, int); 3253 int, int, EMACS_INT, EMACS_INT);
3240void blank_row (struct window *, struct glyph_row *, int); 3254void blank_row (struct window *, struct glyph_row *, int);
3241void increment_row_positions (struct glyph_row *, int, int); 3255void increment_row_positions (struct glyph_row *, EMACS_INT, EMACS_INT);
3242void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int); 3256void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int);
3243void clear_glyph_row (struct glyph_row *); 3257void clear_glyph_row (struct glyph_row *);
3244void prepare_desired_row (struct glyph_row *); 3258void prepare_desired_row (struct glyph_row *);
diff --git a/src/dispnew.c b/src/dispnew.c
index 9344d792f3d..f9729fc28cb 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -849,7 +849,8 @@ rotate_matrix (struct glyph_matrix *matrix, int first, int last, int by)
849 DELTA_BYTES. */ 849 DELTA_BYTES. */
850 850
851void 851void
852increment_matrix_positions (struct glyph_matrix *matrix, int start, int end, int delta, int delta_bytes) 852increment_matrix_positions (struct glyph_matrix *matrix, int start, int end,
853 EMACS_INT delta, EMACS_INT delta_bytes)
853{ 854{
854 /* Check that START and END are reasonable values. */ 855 /* Check that START and END are reasonable values. */
855 xassert (start >= 0 && start <= matrix->nrows); 856 xassert (start >= 0 && start <= matrix->nrows);
@@ -1088,7 +1089,8 @@ blank_row (struct window *w, struct glyph_row *row, int y)
1088 ends. */ 1089 ends. */
1089 1090
1090void 1091void
1091increment_row_positions (struct glyph_row *row, int delta, int delta_bytes) 1092increment_row_positions (struct glyph_row *row,
1093 EMACS_INT delta, EMACS_INT delta_bytes)
1092{ 1094{
1093 int area, i; 1095 int area, i;
1094 1096
@@ -1200,7 +1202,8 @@ copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
1200 positions in row TO by DELTA/ DELTA_BYTES. */ 1202 positions in row TO by DELTA/ DELTA_BYTES. */
1201 1203
1202void 1204void
1203copy_glyph_row_contents (struct glyph_row *to, struct glyph_row *from, int delta, int delta_bytes) 1205copy_glyph_row_contents (struct glyph_row *to, struct glyph_row *from,
1206 EMACS_INT delta, EMACS_INT delta_bytes)
1204{ 1207{
1205 int area; 1208 int area;
1206 1209
@@ -5420,6 +5423,22 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5420 if (STRINGP (it.string)) 5423 if (STRINGP (it.string))
5421 string = it.string; 5424 string = it.string;
5422 *pos = it.current; 5425 *pos = it.current;
5426 if (it.what == IT_COMPOSITION
5427 && it.cmp_it.nchars > 1
5428 && it.cmp_it.reversed_p)
5429 {
5430 /* The current display element is a grapheme cluster in a
5431 composition. In that case, we need the position of the first
5432 character of the cluster. But, as it.cmp_it.reversed_p is 1,
5433 it.current points to the last character of the cluster, thus
5434 we must move back to the first character of the same
5435 cluster. */
5436 CHARPOS (pos->pos) -= it.cmp_it.nchars - 1;
5437 if (STRINGP (it.string))
5438 BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
5439 else
5440 BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos));
5441 }
5423 5442
5424#ifdef HAVE_WINDOW_SYSTEM 5443#ifdef HAVE_WINDOW_SYSTEM
5425 if (it.what == IT_IMAGE) 5444 if (it.what == IT_IMAGE)
@@ -5441,8 +5460,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5441 if (img) 5460 if (img)
5442 { 5461 {
5443 *dy -= row->ascent - glyph->ascent; 5462 *dy -= row->ascent - glyph->ascent;
5444 *dx += glyph->slice.x; 5463 *dx += glyph->slice.img.x;
5445 *dy += glyph->slice.y; 5464 *dy += glyph->slice.img.y;
5446 /* Image slices positions are still relative to the entire image */ 5465 /* Image slices positions are still relative to the entire image */
5447 *width = img->width; 5466 *width = img->width;
5448 *height = img->height; 5467 *height = img->height;
@@ -5482,7 +5501,9 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5482 *CHARPOS is set to the position in the string returned. */ 5501 *CHARPOS is set to the position in the string returned. */
5483 5502
5484Lisp_Object 5503Lisp_Object
5485mode_line_string (struct window *w, enum window_part part, int *x, int *y, int *charpos, Lisp_Object *object, int *dx, int *dy, int *width, int *height) 5504mode_line_string (struct window *w, enum window_part part,
5505 int *x, int *y, EMACS_INT *charpos, Lisp_Object *object,
5506 int *dx, int *dy, int *width, int *height)
5486{ 5507{
5487 struct glyph_row *row; 5508 struct glyph_row *row;
5488 struct glyph *glyph, *end; 5509 struct glyph *glyph, *end;
@@ -5549,7 +5570,9 @@ mode_line_string (struct window *w, enum window_part part, int *x, int *y, int *
5549 the string returned. */ 5570 the string returned. */
5550 5571
5551Lisp_Object 5572Lisp_Object
5552marginal_area_string (struct window *w, enum window_part part, int *x, int *y, int *charpos, Lisp_Object *object, int *dx, int *dy, int *width, int *height) 5573marginal_area_string (struct window *w, enum window_part part,
5574 int *x, int *y, EMACS_INT *charpos, Lisp_Object *object,
5575 int *dx, int *dy, int *width, int *height)
5553{ 5576{
5554 struct glyph_row *row = w->current_matrix->rows; 5577 struct glyph_row *row = w->current_matrix->rows;
5555 struct glyph *glyph, *end; 5578 struct glyph *glyph, *end;
@@ -5604,8 +5627,8 @@ marginal_area_string (struct window *w, enum window_part part, int *x, int *y, i
5604 if (img != NULL) 5627 if (img != NULL)
5605 *object = img->spec; 5628 *object = img->spec;
5606 y0 -= row->ascent - glyph->ascent; 5629 y0 -= row->ascent - glyph->ascent;
5607 x0 += glyph->slice.x; 5630 x0 += glyph->slice.img.x;
5608 y0 += glyph->slice.y; 5631 y0 += glyph->slice.img.y;
5609 } 5632 }
5610#endif 5633#endif
5611 } 5634 }
diff --git a/src/doc.c b/src/doc.c
index 86d29a5a5ef..8ec94f9836c 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -100,8 +100,8 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
100 register int fd; 100 register int fd;
101 register char *name; 101 register char *name;
102 register char *p, *p1; 102 register char *p, *p1;
103 int minsize; 103 EMACS_INT minsize;
104 int offset, position; 104 EMACS_INT offset, position;
105 Lisp_Object file, tem; 105 Lisp_Object file, tem;
106 106
107 if (INTEGERP (filepos)) 107 if (INTEGERP (filepos))
@@ -180,14 +180,14 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
180 p = get_doc_string_buffer; 180 p = get_doc_string_buffer;
181 while (1) 181 while (1)
182 { 182 {
183 int space_left = (get_doc_string_buffer_size 183 EMACS_INT space_left = (get_doc_string_buffer_size
184 - (p - get_doc_string_buffer)); 184 - (p - get_doc_string_buffer));
185 int nread; 185 int nread;
186 186
187 /* Allocate or grow the buffer if we need to. */ 187 /* Allocate or grow the buffer if we need to. */
188 if (space_left == 0) 188 if (space_left == 0)
189 { 189 {
190 int in_buffer = p - get_doc_string_buffer; 190 EMACS_INT in_buffer = p - get_doc_string_buffer;
191 get_doc_string_buffer_size += 16 * 1024; 191 get_doc_string_buffer_size += 16 * 1024;
192 get_doc_string_buffer 192 get_doc_string_buffer
193 = (char *) xrealloc (get_doc_string_buffer, 193 = (char *) xrealloc (get_doc_string_buffer,
@@ -287,8 +287,8 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
287 else 287 else
288 { 288 {
289 /* The data determines whether the string is multibyte. */ 289 /* The data determines whether the string is multibyte. */
290 int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, 290 EMACS_INT nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
291 to - (get_doc_string_buffer + offset)); 291 to - (get_doc_string_buffer + offset));
292 return make_string_from_bytes (get_doc_string_buffer + offset, 292 return make_string_from_bytes (get_doc_string_buffer + offset,
293 nchars, 293 nchars,
294 to - (get_doc_string_buffer + offset)); 294 to - (get_doc_string_buffer + offset));
@@ -561,8 +561,8 @@ the same file name is found in the `doc-directory'. */)
561{ 561{
562 int fd; 562 int fd;
563 char buf[1024 + 1]; 563 char buf[1024 + 1];
564 register int filled; 564 register EMACS_INT filled;
565 register int pos; 565 register EMACS_INT pos;
566 register char *p, *end; 566 register char *p, *end;
567 Lisp_Object sym; 567 Lisp_Object sym;
568 char *name; 568 char *name;
@@ -596,7 +596,7 @@ the same file name is found in the `doc-directory'. */)
596 596
597 for (beg = buildobj; *beg; beg = end) 597 for (beg = buildobj; *beg; beg = end)
598 { 598 {
599 int len; 599 EMACS_INT len;
600 600
601 while (*beg && isspace (*beg)) ++beg; 601 while (*beg && isspace (*beg)) ++beg;
602 602
@@ -643,7 +643,7 @@ the same file name is found in the `doc-directory'. */)
643 if (end - p > 4 && end[-2] == '.' 643 if (end - p > 4 && end[-2] == '.'
644 && (end[-1] == 'o' || end[-1] == 'c')) 644 && (end[-1] == 'o' || end[-1] == 'c'))
645 { 645 {
646 int len = end - p - 2; 646 EMACS_INT len = end - p - 2;
647 char *fromfile = alloca (len + 1); 647 char *fromfile = alloca (len + 1);
648 strncpy (fromfile, &p[2], len); 648 strncpy (fromfile, &p[2], len);
649 fromfile[len] = 0; 649 fromfile[len] = 0;
@@ -688,7 +688,7 @@ the same file name is found in the `doc-directory'. */)
688 } 688 }
689 pos += end - buf; 689 pos += end - buf;
690 filled -= end - buf; 690 filled -= end - buf;
691 memcpy (buf, end, filled); 691 memmove (buf, end, filled);
692 } 692 }
693 emacs_close (fd); 693 emacs_close (fd);
694 return Qnil; 694 return Qnil;
@@ -715,16 +715,16 @@ a new string, without any text properties, is returned. */)
715 int changed = 0; 715 int changed = 0;
716 register unsigned char *strp; 716 register unsigned char *strp;
717 register unsigned char *bufp; 717 register unsigned char *bufp;
718 int idx; 718 EMACS_INT idx;
719 int bsize; 719 EMACS_INT bsize;
720 Lisp_Object tem; 720 Lisp_Object tem;
721 Lisp_Object keymap; 721 Lisp_Object keymap;
722 unsigned char *start; 722 unsigned char *start;
723 int length, length_byte; 723 EMACS_INT length, length_byte;
724 Lisp_Object name; 724 Lisp_Object name;
725 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 725 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
726 int multibyte; 726 int multibyte;
727 int nchars; 727 EMACS_INT nchars;
728 728
729 if (NILP (string)) 729 if (NILP (string))
730 return Qnil; 730 return Qnil;
@@ -776,7 +776,7 @@ a new string, without any text properties, is returned. */)
776 } 776 }
777 else if (strp[0] == '\\' && strp[1] == '[') 777 else if (strp[0] == '\\' && strp[1] == '[')
778 { 778 {
779 int start_idx; 779 EMACS_INT start_idx;
780 int follow_remap = 1; 780 int follow_remap = 1;
781 781
782 changed = 1; 782 changed = 1;
@@ -815,7 +815,7 @@ a new string, without any text properties, is returned. */)
815 815
816 if (NILP (tem)) /* but not on any keys */ 816 if (NILP (tem)) /* but not on any keys */
817 { 817 {
818 int offset = bufp - buf; 818 EMACS_INT offset = bufp - buf;
819 buf = (unsigned char *) xrealloc (buf, bsize += 4); 819 buf = (unsigned char *) xrealloc (buf, bsize += 4);
820 bufp = buf + offset; 820 bufp = buf + offset;
821 memcpy (bufp, "M-x ", 4); 821 memcpy (bufp, "M-x ", 4);
@@ -838,7 +838,7 @@ a new string, without any text properties, is returned. */)
838 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) 838 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
839 { 839 {
840 struct buffer *oldbuf; 840 struct buffer *oldbuf;
841 int start_idx; 841 EMACS_INT start_idx;
842 /* This is for computing the SHADOWS arg for describe_map_tree. */ 842 /* This is for computing the SHADOWS arg for describe_map_tree. */
843 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); 843 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
844 Lisp_Object earlier_maps; 844 Lisp_Object earlier_maps;
@@ -909,7 +909,7 @@ a new string, without any text properties, is returned. */)
909 length_byte = SBYTES (tem); 909 length_byte = SBYTES (tem);
910 subst: 910 subst:
911 { 911 {
912 int offset = bufp - buf; 912 EMACS_INT offset = bufp - buf;
913 buf = (unsigned char *) xrealloc (buf, bsize += length_byte); 913 buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
914 bufp = buf + offset; 914 bufp = buf + offset;
915 memcpy (bufp, start, length_byte); 915 memcpy (bufp, start, length_byte);
diff --git a/src/doprnt.c b/src/doprnt.c
index 1b45b21e36b..02adc51f1e5 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -33,21 +33,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33#include <unistd.h> 33#include <unistd.h>
34#endif 34#endif
35 35
36#ifdef HAVE_STDLIB_H
37#include <stdlib.h>
38#endif
39
40#include "lisp.h" 36#include "lisp.h"
41 37
42#ifndef DBL_MAX_10_EXP
43#define DBL_MAX_10_EXP 308 /* IEEE double */
44#endif
45
46/* Since we use the macro CHAR_HEAD_P, we have to include this, but 38/* Since we use the macro CHAR_HEAD_P, we have to include this, but
47 don't have to include others because CHAR_HEAD_P does not contains 39 don't have to include others because CHAR_HEAD_P does not contains
48 another macro. */ 40 another macro. */
49#include "character.h" 41#include "character.h"
50 42
43#ifndef DBL_MAX_10_EXP
44#define DBL_MAX_10_EXP 308 /* IEEE double */
45#endif
46
51/* Generate output from a format-spec FORMAT, 47/* Generate output from a format-spec FORMAT,
52 terminated at position FORMAT_END. 48 terminated at position FORMAT_END.
53 Output goes in BUFFER, which has room for BUFSIZE chars. 49 Output goes in BUFFER, which has room for BUFSIZE chars.
@@ -58,7 +54,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58 String arguments are passed as C strings. 54 String arguments are passed as C strings.
59 Integers are passed as C integers. */ 55 Integers are passed as C integers. */
60 56
61int 57EMACS_INT
62doprnt (char *buffer, register int bufsize, const char *format, 58doprnt (char *buffer, register int bufsize, const char *format,
63 const char *format_end, va_list ap) 59 const char *format_end, va_list ap)
64{ 60{
@@ -100,7 +96,7 @@ doprnt (char *buffer, register int bufsize, const char *format,
100 if (*fmt == '%') /* Check for a '%' character */ 96 if (*fmt == '%') /* Check for a '%' character */
101 { 97 {
102 unsigned size_bound = 0; 98 unsigned size_bound = 0;
103 int width; /* Columns occupied by STRING. */ 99 EMACS_INT width; /* Columns occupied by STRING. */
104 100
105 fmt++; 101 fmt++;
106 /* Copy this one %-spec into fmtcpy. */ 102 /* Copy this one %-spec into fmtcpy. */
diff --git a/src/editfns.c b/src/editfns.c
index 1bd6682c3b6..f76beb5e678 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -94,8 +94,9 @@ extern Lisp_Object w32_get_internal_run_time (void);
94#endif 94#endif
95 95
96static int tm_diff (struct tm *, struct tm *); 96static int tm_diff (struct tm *, struct tm *);
97static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *); 97static void find_field (Lisp_Object, Lisp_Object, Lisp_Object,
98static void update_buffer_properties (int, int); 98 EMACS_INT *, Lisp_Object, EMACS_INT *);
99static void update_buffer_properties (EMACS_INT, EMACS_INT);
99static Lisp_Object region_limit (int); 100static Lisp_Object region_limit (int);
100static size_t emacs_memftimeu (char *, size_t, const char *, 101static size_t emacs_memftimeu (char *, size_t, const char *,
101 size_t, const struct tm *, int); 102 size_t, const struct tm *, int);
@@ -106,7 +107,8 @@ static void general_insert_function (void (*) (const unsigned char *, EMACS_INT)
106 int, int, Lisp_Object *); 107 int, int, Lisp_Object *);
107static Lisp_Object subst_char_in_region_unwind (Lisp_Object); 108static Lisp_Object subst_char_in_region_unwind (Lisp_Object);
108static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object); 109static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object);
109static void transpose_markers (int, int, int, int, int, int, int, int); 110static void transpose_markers (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
111 EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT);
110 112
111Lisp_Object Vbuffer_access_fontify_functions; 113Lisp_Object Vbuffer_access_fontify_functions;
112Lisp_Object Qbuffer_access_fontify_functions; 114Lisp_Object Qbuffer_access_fontify_functions;
@@ -245,7 +247,7 @@ A multibyte character is handled correctly. */)
245} 247}
246 248
247static Lisp_Object 249static Lisp_Object
248buildmark (int charpos, int bytepos) 250buildmark (EMACS_INT charpos, EMACS_INT bytepos)
249{ 251{
250 register Lisp_Object mark; 252 register Lisp_Object mark;
251 mark = Fmake_marker (); 253 mark = Fmake_marker ();
@@ -270,8 +272,8 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0,
270 return buildmark (PT, PT_BYTE); 272 return buildmark (PT, PT_BYTE);
271} 273}
272 274
273int 275EMACS_INT
274clip_to_bounds (int lower, int num, int upper) 276clip_to_bounds (EMACS_INT lower, EMACS_INT num, EMACS_INT upper)
275{ 277{
276 if (num < lower) 278 if (num < lower)
277 return lower; 279 return lower;
@@ -288,7 +290,7 @@ Beginning of buffer is position (point-min), end is (point-max).
288The return value is POSITION. */) 290The return value is POSITION. */)
289 (register Lisp_Object position) 291 (register Lisp_Object position)
290{ 292{
291 int pos; 293 EMACS_INT pos;
292 294
293 if (MARKERP (position) 295 if (MARKERP (position)
294 && current_buffer == XMARKER (position)->buffer) 296 && current_buffer == XMARKER (position)->buffer)
@@ -364,11 +366,11 @@ If you set the marker not to point anywhere, the buffer will have no mark. */)
364 of length LEN. */ 366 of length LEN. */
365 367
366static int 368static int
367overlays_around (int pos, Lisp_Object *vec, int len) 369overlays_around (EMACS_INT pos, Lisp_Object *vec, int len)
368{ 370{
369 Lisp_Object overlay, start, end; 371 Lisp_Object overlay, start, end;
370 struct Lisp_Overlay *tail; 372 struct Lisp_Overlay *tail;
371 int startpos, endpos; 373 EMACS_INT startpos, endpos;
372 int idx = 0; 374 int idx = 0;
373 375
374 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 376 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
@@ -436,7 +438,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
436 return Fget_text_property (position, prop, object); 438 return Fget_text_property (position, prop, object);
437 else 439 else
438 { 440 {
439 int posn = XINT (position); 441 EMACS_INT posn = XINT (position);
440 int noverlays; 442 int noverlays;
441 Lisp_Object *overlay_vec, tem; 443 Lisp_Object *overlay_vec, tem;
442 struct buffer *obuf = current_buffer; 444 struct buffer *obuf = current_buffer;
@@ -515,7 +517,9 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
515 is not stored. */ 517 is not stored. */
516 518
517static void 519static void
518find_field (Lisp_Object pos, Lisp_Object merge_at_boundary, Lisp_Object beg_limit, int *beg, Lisp_Object end_limit, int *end) 520find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
521 Lisp_Object beg_limit,
522 EMACS_INT *beg, Lisp_Object end_limit, EMACS_INT *end)
519{ 523{
520 /* Fields right before and after the point. */ 524 /* Fields right before and after the point. */
521 Lisp_Object before_field, after_field; 525 Lisp_Object before_field, after_field;
@@ -631,7 +635,7 @@ A field is a region of text with the same `field' property.
631If POS is nil, the value of point is used for POS. */) 635If POS is nil, the value of point is used for POS. */)
632 (Lisp_Object pos) 636 (Lisp_Object pos)
633{ 637{
634 int beg, end; 638 EMACS_INT beg, end;
635 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); 639 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
636 if (beg != end) 640 if (beg != end)
637 del_range (beg, end); 641 del_range (beg, end);
@@ -644,7 +648,7 @@ A field is a region of text with the same `field' property.
644If POS is nil, the value of point is used for POS. */) 648If POS is nil, the value of point is used for POS. */)
645 (Lisp_Object pos) 649 (Lisp_Object pos)
646{ 650{
647 int beg, end; 651 EMACS_INT beg, end;
648 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); 652 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
649 return make_buffer_string (beg, end, 1); 653 return make_buffer_string (beg, end, 1);
650} 654}
@@ -655,7 +659,7 @@ A field is a region of text with the same `field' property.
655If POS is nil, the value of point is used for POS. */) 659If POS is nil, the value of point is used for POS. */)
656 (Lisp_Object pos) 660 (Lisp_Object pos)
657{ 661{
658 int beg, end; 662 EMACS_INT beg, end;
659 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); 663 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
660 return make_buffer_string (beg, end, 0); 664 return make_buffer_string (beg, end, 0);
661} 665}
@@ -670,7 +674,7 @@ If LIMIT is non-nil, it is a buffer position; if the beginning of the field
670is before LIMIT, then LIMIT will be returned instead. */) 674is before LIMIT, then LIMIT will be returned instead. */)
671 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit) 675 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit)
672{ 676{
673 int beg; 677 EMACS_INT beg;
674 find_field (pos, escape_from_edge, limit, &beg, Qnil, 0); 678 find_field (pos, escape_from_edge, limit, &beg, Qnil, 0);
675 return make_number (beg); 679 return make_number (beg);
676} 680}
@@ -685,7 +689,7 @@ If LIMIT is non-nil, it is a buffer position; if the end of the field
685is after LIMIT, then LIMIT will be returned instead. */) 689is after LIMIT, then LIMIT will be returned instead. */)
686 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit) 690 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit)
687{ 691{
688 int end; 692 EMACS_INT end;
689 find_field (pos, escape_from_edge, Qnil, 0, limit, &end); 693 find_field (pos, escape_from_edge, Qnil, 0, limit, &end);
690 return make_number (end); 694 return make_number (end);
691} 695}
@@ -720,7 +724,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
720 (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge, Lisp_Object only_in_line, Lisp_Object inhibit_capture_property) 724 (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge, Lisp_Object only_in_line, Lisp_Object inhibit_capture_property)
721{ 725{
722 /* If non-zero, then the original point, before re-positioning. */ 726 /* If non-zero, then the original point, before re-positioning. */
723 int orig_point = 0; 727 EMACS_INT orig_point = 0;
724 int fwd; 728 int fwd;
725 Lisp_Object prev_old, prev_new; 729 Lisp_Object prev_old, prev_new;
726 730
@@ -817,7 +821,7 @@ boundaries bind `inhibit-field-text-motion' to t.
817This function does not move point. */) 821This function does not move point. */)
818 (Lisp_Object n) 822 (Lisp_Object n)
819{ 823{
820 int orig, orig_byte, end; 824 EMACS_INT orig, orig_byte, end;
821 int count = SPECPDL_INDEX (); 825 int count = SPECPDL_INDEX ();
822 specbind (Qinhibit_point_motion_hooks, Qt); 826 specbind (Qinhibit_point_motion_hooks, Qt);
823 827
@@ -858,8 +862,8 @@ boundaries bind `inhibit-field-text-motion' to t.
858This function does not move point. */) 862This function does not move point. */)
859 (Lisp_Object n) 863 (Lisp_Object n)
860{ 864{
861 int end_pos; 865 EMACS_INT end_pos;
862 int orig = PT; 866 EMACS_INT orig = PT;
863 867
864 if (NILP (n)) 868 if (NILP (n))
865 XSETFASTINT (n, 1); 869 XSETFASTINT (n, 1);
@@ -1131,7 +1135,7 @@ At the beginning of the buffer or accessible region, return 0. */)
1131 XSETFASTINT (temp, 0); 1135 XSETFASTINT (temp, 0);
1132 else if (!NILP (current_buffer->enable_multibyte_characters)) 1136 else if (!NILP (current_buffer->enable_multibyte_characters))
1133 { 1137 {
1134 int pos = PT_BYTE; 1138 EMACS_INT pos = PT_BYTE;
1135 DEC_POS (pos); 1139 DEC_POS (pos);
1136 XSETFASTINT (temp, FETCH_CHAR (pos)); 1140 XSETFASTINT (temp, FETCH_CHAR (pos));
1137 } 1141 }
@@ -1185,7 +1189,7 @@ POS is an integer or a marker and defaults to point.
1185If POS is out of range, the value is nil. */) 1189If POS is out of range, the value is nil. */)
1186 (Lisp_Object pos) 1190 (Lisp_Object pos)
1187{ 1191{
1188 register int pos_byte; 1192 register EMACS_INT pos_byte;
1189 1193
1190 if (NILP (pos)) 1194 if (NILP (pos))
1191 { 1195 {
@@ -1218,7 +1222,7 @@ If POS is out of range, the value is nil. */)
1218 (Lisp_Object pos) 1222 (Lisp_Object pos)
1219{ 1223{
1220 register Lisp_Object val; 1224 register Lisp_Object val;
1221 register int pos_byte; 1225 register EMACS_INT pos_byte;
1222 1226
1223 if (NILP (pos)) 1227 if (NILP (pos))
1224 { 1228 {
@@ -2266,8 +2270,9 @@ from adjoining text, if those properties are sticky. */)
2266 (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) 2270 (Lisp_Object character, Lisp_Object count, Lisp_Object inherit)
2267{ 2271{
2268 register unsigned char *string; 2272 register unsigned char *string;
2269 register int strlen; 2273 register EMACS_INT strlen;
2270 register int i, n; 2274 register int i;
2275 register EMACS_INT n;
2271 int len; 2276 int len;
2272 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2277 unsigned char str[MAX_MULTIBYTE_LENGTH];
2273 2278
@@ -2278,6 +2283,8 @@ from adjoining text, if those properties are sticky. */)
2278 len = CHAR_STRING (XFASTINT (character), str); 2283 len = CHAR_STRING (XFASTINT (character), str);
2279 else 2284 else
2280 str[0] = XFASTINT (character), len = 1; 2285 str[0] = XFASTINT (character), len = 1;
2286 if (MOST_POSITIVE_FIXNUM / len < XINT (count))
2287 error ("Maximum buffer size would be exceeded");
2281 n = XINT (count) * len; 2288 n = XINT (count) * len;
2282 if (n <= 0) 2289 if (n <= 0)
2283 return Qnil; 2290 return Qnil;
@@ -2343,10 +2350,10 @@ from adjoining text, if those properties are sticky. */)
2343 buffer substrings. */ 2350 buffer substrings. */
2344 2351
2345Lisp_Object 2352Lisp_Object
2346make_buffer_string (int start, int end, int props) 2353make_buffer_string (EMACS_INT start, EMACS_INT end, int props)
2347{ 2354{
2348 int start_byte = CHAR_TO_BYTE (start); 2355 EMACS_INT start_byte = CHAR_TO_BYTE (start);
2349 int end_byte = CHAR_TO_BYTE (end); 2356 EMACS_INT end_byte = CHAR_TO_BYTE (end);
2350 2357
2351 return make_buffer_string_both (start, start_byte, end, end_byte, props); 2358 return make_buffer_string_both (start, start_byte, end, end_byte, props);
2352} 2359}
@@ -2367,7 +2374,8 @@ make_buffer_string (int start, int end, int props)
2367 buffer substrings. */ 2374 buffer substrings. */
2368 2375
2369Lisp_Object 2376Lisp_Object
2370make_buffer_string_both (int start, int start_byte, int end, int end_byte, int props) 2377make_buffer_string_both (EMACS_INT start, EMACS_INT start_byte,
2378 EMACS_INT end, EMACS_INT end_byte, int props)
2371{ 2379{
2372 Lisp_Object result, tem, tem1; 2380 Lisp_Object result, tem, tem1;
2373 2381
@@ -2400,7 +2408,7 @@ make_buffer_string_both (int start, int start_byte, int end, int end_byte, int p
2400 in the current buffer, if necessary. */ 2408 in the current buffer, if necessary. */
2401 2409
2402static void 2410static void
2403update_buffer_properties (int start, int end) 2411update_buffer_properties (EMACS_INT start, EMACS_INT end)
2404{ 2412{
2405 /* If this buffer has some access functions, 2413 /* If this buffer has some access functions,
2406 call them, specifying the range of the buffer being accessed. */ 2414 call them, specifying the range of the buffer being accessed. */
@@ -2439,7 +2447,7 @@ into the result string; if you don't want the text properties,
2439use `buffer-substring-no-properties' instead. */) 2447use `buffer-substring-no-properties' instead. */)
2440 (Lisp_Object start, Lisp_Object end) 2448 (Lisp_Object start, Lisp_Object end)
2441{ 2449{
2442 register int b, e; 2450 register EMACS_INT b, e;
2443 2451
2444 validate_region (&start, &end); 2452 validate_region (&start, &end);
2445 b = XINT (start); 2453 b = XINT (start);
@@ -2455,7 +2463,7 @@ The two arguments START and END are character positions;
2455they can be in either order. */) 2463they can be in either order. */)
2456 (Lisp_Object start, Lisp_Object end) 2464 (Lisp_Object start, Lisp_Object end)
2457{ 2465{
2458 register int b, e; 2466 register EMACS_INT b, e;
2459 2467
2460 validate_region (&start, &end); 2468 validate_region (&start, &end);
2461 b = XINT (start); 2469 b = XINT (start);
@@ -2481,7 +2489,7 @@ Arguments START and END are character positions specifying the substring.
2481They default to the values of (point-min) and (point-max) in BUFFER. */) 2489They default to the values of (point-min) and (point-max) in BUFFER. */)
2482 (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) 2490 (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
2483{ 2491{
2484 register int b, e, temp; 2492 register EMACS_INT b, e, temp;
2485 register struct buffer *bp, *obuf; 2493 register struct buffer *bp, *obuf;
2486 Lisp_Object buf; 2494 Lisp_Object buf;
2487 2495
@@ -2534,13 +2542,13 @@ The value of `case-fold-search' in the current buffer
2534determines whether case is significant or ignored. */) 2542determines whether case is significant or ignored. */)
2535 (Lisp_Object buffer1, Lisp_Object start1, Lisp_Object end1, Lisp_Object buffer2, Lisp_Object start2, Lisp_Object end2) 2543 (Lisp_Object buffer1, Lisp_Object start1, Lisp_Object end1, Lisp_Object buffer2, Lisp_Object start2, Lisp_Object end2)
2536{ 2544{
2537 register int begp1, endp1, begp2, endp2, temp; 2545 register EMACS_INT begp1, endp1, begp2, endp2, temp;
2538 register struct buffer *bp1, *bp2; 2546 register struct buffer *bp1, *bp2;
2539 register Lisp_Object trt 2547 register Lisp_Object trt
2540 = (!NILP (current_buffer->case_fold_search) 2548 = (!NILP (current_buffer->case_fold_search)
2541 ? current_buffer->case_canon_table : Qnil); 2549 ? current_buffer->case_canon_table : Qnil);
2542 int chars = 0; 2550 EMACS_INT chars = 0;
2543 int i1, i2, i1_byte, i2_byte; 2551 EMACS_INT i1, i2, i1_byte, i2_byte;
2544 2552
2545 /* Find the first buffer and its substring. */ 2553 /* Find the first buffer and its substring. */
2546 2554
@@ -2701,12 +2709,12 @@ and don't mark the buffer as really changed.
2701Both characters must have the same length of multi-byte form. */) 2709Both characters must have the same length of multi-byte form. */)
2702 (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo) 2710 (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo)
2703{ 2711{
2704 register int pos, pos_byte, stop, i, len, end_byte; 2712 register EMACS_INT pos, pos_byte, stop, i, len, end_byte;
2705 /* Keep track of the first change in the buffer: 2713 /* Keep track of the first change in the buffer:
2706 if 0 we haven't found it yet. 2714 if 0 we haven't found it yet.
2707 if < 0 we've found it and we've run the before-change-function. 2715 if < 0 we've found it and we've run the before-change-function.
2708 if > 0 we've actually performed it and the value is its position. */ 2716 if > 0 we've actually performed it and the value is its position. */
2709 int changed = 0; 2717 EMACS_INT changed = 0;
2710 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; 2718 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
2711 unsigned char *p; 2719 unsigned char *p;
2712 int count = SPECPDL_INDEX (); 2720 int count = SPECPDL_INDEX ();
@@ -2715,7 +2723,7 @@ Both characters must have the same length of multi-byte form. */)
2715#define COMBINING_AFTER 2 2723#define COMBINING_AFTER 2
2716#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) 2724#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
2717 int maybe_byte_combining = COMBINING_NO; 2725 int maybe_byte_combining = COMBINING_NO;
2718 int last_changed = 0; 2726 EMACS_INT last_changed = 0;
2719 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); 2727 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
2720 2728
2721 restart: 2729 restart:
@@ -2772,7 +2780,7 @@ Both characters must have the same length of multi-byte form. */)
2772 stop = min (stop, GPT_BYTE); 2780 stop = min (stop, GPT_BYTE);
2773 while (1) 2781 while (1)
2774 { 2782 {
2775 int pos_byte_next = pos_byte; 2783 EMACS_INT pos_byte_next = pos_byte;
2776 2784
2777 if (pos_byte >= stop) 2785 if (pos_byte >= stop)
2778 { 2786 {
@@ -2875,7 +2883,8 @@ Both characters must have the same length of multi-byte form. */)
2875} 2883}
2876 2884
2877 2885
2878static Lisp_Object check_translation (int, int, int, Lisp_Object); 2886static Lisp_Object check_translation (EMACS_INT, EMACS_INT, EMACS_INT,
2887 Lisp_Object);
2879 2888
2880/* Helper function for Ftranslate_region_internal. 2889/* Helper function for Ftranslate_region_internal.
2881 2890
@@ -2884,7 +2893,8 @@ static Lisp_Object check_translation (int, int, int, Lisp_Object);
2884 element is found, return it. Otherwise return Qnil. */ 2893 element is found, return it. Otherwise return Qnil. */
2885 2894
2886static Lisp_Object 2895static Lisp_Object
2887check_translation (int pos, int pos_byte, int end, Lisp_Object val) 2896check_translation (EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT end,
2897 Lisp_Object val)
2888{ 2898{
2889 int buf_size = 16, buf_used = 0; 2899 int buf_size = 16, buf_used = 0;
2890 int *buf = alloca (sizeof (int) * buf_size); 2900 int *buf = alloca (sizeof (int) * buf_size);
@@ -2892,7 +2902,7 @@ check_translation (int pos, int pos_byte, int end, Lisp_Object val)
2892 for (; CONSP (val); val = XCDR (val)) 2902 for (; CONSP (val); val = XCDR (val))
2893 { 2903 {
2894 Lisp_Object elt; 2904 Lisp_Object elt;
2895 int len, i; 2905 EMACS_INT len, i;
2896 2906
2897 elt = XCAR (val); 2907 elt = XCAR (val);
2898 if (! CONSP (elt)) 2908 if (! CONSP (elt))
@@ -2908,7 +2918,7 @@ check_translation (int pos, int pos_byte, int end, Lisp_Object val)
2908 if (buf_used <= i) 2918 if (buf_used <= i)
2909 { 2919 {
2910 unsigned char *p = BYTE_POS_ADDR (pos_byte); 2920 unsigned char *p = BYTE_POS_ADDR (pos_byte);
2911 int len; 2921 int len1;
2912 2922
2913 if (buf_used == buf_size) 2923 if (buf_used == buf_size)
2914 { 2924 {
@@ -2919,8 +2929,8 @@ check_translation (int pos, int pos_byte, int end, Lisp_Object val)
2919 memcpy (newbuf, buf, sizeof (int) * buf_used); 2929 memcpy (newbuf, buf, sizeof (int) * buf_used);
2920 buf = newbuf; 2930 buf = newbuf;
2921 } 2931 }
2922 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len); 2932 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len1);
2923 pos_byte += len; 2933 pos_byte += len1;
2924 } 2934 }
2925 if (XINT (AREF (elt, i)) != buf[i]) 2935 if (XINT (AREF (elt, i)) != buf[i])
2926 break; 2936 break;
@@ -2945,8 +2955,8 @@ It returns the number of characters changed. */)
2945 register unsigned char *tt; /* Trans table. */ 2955 register unsigned char *tt; /* Trans table. */
2946 register int nc; /* New character. */ 2956 register int nc; /* New character. */
2947 int cnt; /* Number of changes made. */ 2957 int cnt; /* Number of changes made. */
2948 int size; /* Size of translate table. */ 2958 EMACS_INT size; /* Size of translate table. */
2949 int pos, pos_byte, end_pos; 2959 EMACS_INT pos, pos_byte, end_pos;
2950 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 2960 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
2951 int string_multibyte; 2961 int string_multibyte;
2952 Lisp_Object val; 2962 Lisp_Object val;
@@ -3016,7 +3026,7 @@ It returns the number of characters changed. */)
3016 } 3026 }
3017 else 3027 else
3018 { 3028 {
3019 int c; 3029 EMACS_INT c;
3020 3030
3021 nc = oc; 3031 nc = oc;
3022 val = CHAR_TABLE_REF (table, oc); 3032 val = CHAR_TABLE_REF (table, oc);
@@ -3229,7 +3239,7 @@ save_restriction_restore (Lisp_Object data)
3229 /* The restriction has changed from the saved one, so restore 3239 /* The restriction has changed from the saved one, so restore
3230 the saved restriction. */ 3240 the saved restriction. */
3231 { 3241 {
3232 int pt = BUF_PT (buf); 3242 EMACS_INT pt = BUF_PT (buf);
3233 3243
3234 SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos); 3244 SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos);
3235 SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos); 3245 SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos);
@@ -3508,7 +3518,7 @@ usage: (format STRING &rest OBJECTS) */)
3508 (int nargs, register Lisp_Object *args) 3518 (int nargs, register Lisp_Object *args)
3509{ 3519{
3510 register int n; /* The number of the next arg to substitute */ 3520 register int n; /* The number of the next arg to substitute */
3511 register int total; /* An estimate of the final length */ 3521 register EMACS_INT total; /* An estimate of the final length */
3512 char *buf, *p; 3522 char *buf, *p;
3513 register unsigned char *format, *end, *format_start; 3523 register unsigned char *format, *end, *format_start;
3514 int nchars; 3524 int nchars;
@@ -3517,7 +3527,7 @@ usage: (format STRING &rest OBJECTS) */)
3517 int multibyte = 0; 3527 int multibyte = 0;
3518 /* When we make a multibyte string, we must pay attention to the 3528 /* When we make a multibyte string, we must pay attention to the
3519 byte combining problem, i.e., a byte may be combined with a 3529 byte combining problem, i.e., a byte may be combined with a
3520 multibyte charcter of the previous string. This flag tells if we 3530 multibyte character of the previous string. This flag tells if we
3521 must consider such a situation or not. */ 3531 must consider such a situation or not. */
3522 int maybe_combine_byte; 3532 int maybe_combine_byte;
3523 unsigned char *this_format; 3533 unsigned char *this_format;
@@ -3602,8 +3612,8 @@ usage: (format STRING &rest OBJECTS) */)
3602 while (format != end) 3612 while (format != end)
3603 if (*format++ == '%') 3613 if (*format++ == '%')
3604 { 3614 {
3605 int thissize = 0; 3615 EMACS_INT thissize = 0;
3606 int actual_width = 0; 3616 EMACS_INT actual_width = 0;
3607 unsigned char *this_format_start = format - 1; 3617 unsigned char *this_format_start = format - 1;
3608 int field_width = 0; 3618 int field_width = 0;
3609 3619
@@ -3845,8 +3855,8 @@ usage: (format STRING &rest OBJECTS) */)
3845 /* handle case (precision[n] >= 0) */ 3855 /* handle case (precision[n] >= 0) */
3846 3856
3847 int width, padding; 3857 int width, padding;
3848 int nbytes, start, end; 3858 EMACS_INT nbytes, start, end;
3849 int nchars_string; 3859 EMACS_INT nchars_string;
3850 3860
3851 /* lisp_string_width ignores a precision of 0, but GNU 3861 /* lisp_string_width ignores a precision of 0, but GNU
3852 libc functions print 0 characters when the precision 3862 libc functions print 0 characters when the precision
@@ -3857,7 +3867,8 @@ usage: (format STRING &rest OBJECTS) */)
3857 if (precision[n] == 0) 3867 if (precision[n] == 0)
3858 width = nchars_string = nbytes = 0; 3868 width = nchars_string = nbytes = 0;
3859 else if (precision[n] > 0) 3869 else if (precision[n] > 0)
3860 width = lisp_string_width (args[n], precision[n], &nchars_string, &nbytes); 3870 width = lisp_string_width (args[n], precision[n],
3871 &nchars_string, &nbytes);
3861 else 3872 else
3862 { /* no precision spec given for this argument */ 3873 { /* no precision spec given for this argument */
3863 width = lisp_string_width (args[n], -1, NULL, NULL); 3874 width = lisp_string_width (args[n], -1, NULL, NULL);
@@ -4016,7 +4027,8 @@ usage: (format STRING &rest OBJECTS) */)
4016 4027
4017 if (CONSP (props)) 4028 if (CONSP (props))
4018 { 4029 {
4019 int bytepos = 0, position = 0, translated = 0, argn = 1; 4030 EMACS_INT bytepos = 0, position = 0, translated = 0;
4031 int argn = 1;
4020 Lisp_Object list; 4032 Lisp_Object list;
4021 4033
4022 /* Adjust the bounds of each text property 4034 /* Adjust the bounds of each text property
@@ -4034,7 +4046,7 @@ usage: (format STRING &rest OBJECTS) */)
4034 for (list = props; CONSP (list); list = XCDR (list)) 4046 for (list = props; CONSP (list); list = XCDR (list))
4035 { 4047 {
4036 Lisp_Object item; 4048 Lisp_Object item;
4037 int pos; 4049 EMACS_INT pos;
4038 4050
4039 item = XCAR (list); 4051 item = XCAR (list);
4040 4052
@@ -4170,11 +4182,12 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer. */)
4170 It's the caller's job to ensure that START1 <= END1 <= START2 <= END2. */ 4182 It's the caller's job to ensure that START1 <= END1 <= START2 <= END2. */
4171 4183
4172static void 4184static void
4173transpose_markers (int start1, int end1, int start2, int end2, 4185transpose_markers (EMACS_INT start1, EMACS_INT end1,
4174 int start1_byte, int end1_byte, 4186 EMACS_INT start2, EMACS_INT end2,
4175 int start2_byte, int end2_byte) 4187 EMACS_INT start1_byte, EMACS_INT end1_byte,
4188 EMACS_INT start2_byte, EMACS_INT end2_byte)
4176{ 4189{
4177 register int amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos; 4190 register EMACS_INT amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos;
4178 register struct Lisp_Marker *marker; 4191 register struct Lisp_Marker *marker;
4179 4192
4180 /* Update point as if it were a marker. */ 4193 /* Update point as if it were a marker. */
@@ -4271,7 +4284,7 @@ Transposing beyond buffer boundaries is an error. */)
4271 /* Swap the regions if they're reversed. */ 4284 /* Swap the regions if they're reversed. */
4272 if (start2 < end1) 4285 if (start2 < end1)
4273 { 4286 {
4274 register int glumph = start1; 4287 register EMACS_INT glumph = start1;
4275 start1 = start2; 4288 start1 = start2;
4276 start2 = glumph; 4289 start2 = glumph;
4277 glumph = end1; 4290 glumph = end1;
diff --git a/src/emacs.c b/src/emacs.c
index 33e0d60630b..397b6d1ce88 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -32,10 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include <unistd.h> 32#include <unistd.h>
33#endif 33#endif
34 34
35#ifdef HAVE_SYS_IOCTL_H
36#include <sys/ioctl.h>
37#endif
38
39#ifdef WINDOWSNT 35#ifdef WINDOWSNT
40#include <fcntl.h> 36#include <fcntl.h>
41#include <windows.h> /* just for w32.h */ 37#include <windows.h> /* just for w32.h */
@@ -63,6 +59,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#include "keyboard.h" 59#include "keyboard.h"
64#include "keymap.h" 60#include "keymap.h"
65 61
62#ifdef HAVE_GNUTLS
63#include "gnutls.h"
64#endif
65
66#ifdef HAVE_NS 66#ifdef HAVE_NS
67#include "nsterm.h" 67#include "nsterm.h"
68#endif 68#endif
@@ -1573,6 +1573,10 @@ main (int argc, char **argv)
1573 syms_of_fontset (); 1573 syms_of_fontset ();
1574#endif /* HAVE_NS */ 1574#endif /* HAVE_NS */
1575 1575
1576#ifdef HAVE_GNUTLS
1577 syms_of_gnutls ();
1578#endif
1579
1576#ifdef HAVE_DBUS 1580#ifdef HAVE_DBUS
1577 syms_of_dbusbind (); 1581 syms_of_dbusbind ();
1578#endif /* HAVE_DBUS */ 1582#endif /* HAVE_DBUS */
diff --git a/src/eval.c b/src/eval.c
index a16d6c59809..6383a672ae3 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -89,7 +89,7 @@ Lisp_Object Vinternal_interpreter_environment;
89 89
90/* Current number of specbindings allocated in specpdl. */ 90/* Current number of specbindings allocated in specpdl. */
91 91
92int specpdl_size; 92EMACS_INT specpdl_size;
93 93
94/* Pointer to beginning of specpdl. */ 94/* Pointer to beginning of specpdl. */
95 95
@@ -105,7 +105,7 @@ EMACS_INT max_specpdl_size;
105 105
106/* Depth in Lisp evaluations and function calls. */ 106/* Depth in Lisp evaluations and function calls. */
107 107
108int lisp_eval_depth; 108EMACS_INT lisp_eval_depth;
109 109
110/* Maximum allowed depth in Lisp evaluations and function calls. */ 110/* Maximum allowed depth in Lisp evaluations and function calls. */
111 111
@@ -227,7 +227,7 @@ call_debugger (Lisp_Object arg)
227 int debug_while_redisplaying; 227 int debug_while_redisplaying;
228 int count = SPECPDL_INDEX (); 228 int count = SPECPDL_INDEX ();
229 Lisp_Object val; 229 Lisp_Object val;
230 int old_max = max_specpdl_size; 230 EMACS_INT old_max = max_specpdl_size;
231 231
232 /* Temporarily bump up the stack limits, 232 /* Temporarily bump up the stack limits,
233 so the debugger won't run out of stack. */ 233 so the debugger won't run out of stack. */
@@ -2065,7 +2065,7 @@ void
2065verror (const char *m, va_list ap) 2065verror (const char *m, va_list ap)
2066{ 2066{
2067 char buf[200]; 2067 char buf[200];
2068 int size = 200; 2068 EMACS_INT size = 200;
2069 int mlen; 2069 int mlen;
2070 char *buffer = buf; 2070 char *buffer = buf;
2071 char *args[3]; 2071 char *args[3];
@@ -2076,7 +2076,7 @@ verror (const char *m, va_list ap)
2076 2076
2077 while (1) 2077 while (1)
2078 { 2078 {
2079 int used; 2079 EMACS_INT used;
2080 used = doprnt (buffer, size, m, m + mlen, ap); 2080 used = doprnt (buffer, size, m, m + mlen, ap);
2081 if (used < size) 2081 if (used < size)
2082 break; 2082 break;
diff --git a/src/fns.c b/src/fns.c
index be4b99d50e6..7bae3bb0fae 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -241,8 +241,8 @@ If string STR1 is greater, the value is a positive number N;
241 N - 1 is the number of characters that match at the beginning. */) 241 N - 1 is the number of characters that match at the beginning. */)
242 (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case) 242 (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case)
243{ 243{
244 register int end1_char, end2_char; 244 register EMACS_INT end1_char, end2_char;
245 register int i1, i1_byte, i2, i2_byte; 245 register EMACS_INT i1, i1_byte, i2, i2_byte;
246 246
247 CHECK_STRING (str1); 247 CHECK_STRING (str1);
248 CHECK_STRING (str2); 248 CHECK_STRING (str2);
@@ -332,8 +332,8 @@ Case is significant.
332Symbols are also allowed; their print names are used instead. */) 332Symbols are also allowed; their print names are used instead. */)
333 (register Lisp_Object s1, Lisp_Object s2) 333 (register Lisp_Object s1, Lisp_Object s2)
334{ 334{
335 register int end; 335 register EMACS_INT end;
336 register int i1, i1_byte, i2, i2_byte; 336 register EMACS_INT i1, i1_byte, i2, i2_byte;
337 337
338 if (SYMBOLP (s1)) 338 if (SYMBOLP (s1))
339 s1 = SYMBOL_NAME (s1); 339 s1 = SYMBOL_NAME (s1);
@@ -456,8 +456,8 @@ with the original. */)
456struct textprop_rec 456struct textprop_rec
457{ 457{
458 int argnum; /* refer to ARGS (arguments of `concat') */ 458 int argnum; /* refer to ARGS (arguments of `concat') */
459 int from; /* refer to ARGS[argnum] (argument string) */ 459 EMACS_INT from; /* refer to ARGS[argnum] (argument string) */
460 int to; /* refer to VAL (the target string) */ 460 EMACS_INT to; /* refer to VAL (the target string) */
461}; 461};
462 462
463static Lisp_Object 463static Lisp_Object
@@ -466,10 +466,10 @@ concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_speci
466 Lisp_Object val; 466 Lisp_Object val;
467 register Lisp_Object tail; 467 register Lisp_Object tail;
468 register Lisp_Object this; 468 register Lisp_Object this;
469 int toindex; 469 EMACS_INT toindex;
470 int toindex_byte = 0; 470 EMACS_INT toindex_byte = 0;
471 register int result_len; 471 register EMACS_INT result_len;
472 register int result_len_byte; 472 register EMACS_INT result_len_byte;
473 register int argnum; 473 register int argnum;
474 Lisp_Object last_tail; 474 Lisp_Object last_tail;
475 Lisp_Object prev; 475 Lisp_Object prev;
@@ -513,16 +513,16 @@ concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_speci
513 some_multibyte = 0; 513 some_multibyte = 0;
514 for (argnum = 0; argnum < nargs; argnum++) 514 for (argnum = 0; argnum < nargs; argnum++)
515 { 515 {
516 int len; 516 EMACS_INT len;
517 this = args[argnum]; 517 this = args[argnum];
518 len = XFASTINT (Flength (this)); 518 len = XFASTINT (Flength (this));
519 if (target_type == Lisp_String) 519 if (target_type == Lisp_String)
520 { 520 {
521 /* We must count the number of bytes needed in the string 521 /* We must count the number of bytes needed in the string
522 as well as the number of characters. */ 522 as well as the number of characters. */
523 int i; 523 EMACS_INT i;
524 Lisp_Object ch; 524 Lisp_Object ch;
525 int this_len_byte; 525 EMACS_INT this_len_byte;
526 526
527 if (VECTORP (this) || FUNVECP (this)) 527 if (VECTORP (this) || FUNVECP (this))
528 for (i = 0; i < len; i++) 528 for (i = 0; i < len; i++)
@@ -594,9 +594,9 @@ concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_speci
594 for (argnum = 0; argnum < nargs; argnum++) 594 for (argnum = 0; argnum < nargs; argnum++)
595 { 595 {
596 Lisp_Object thislen; 596 Lisp_Object thislen;
597 int thisleni = 0; 597 EMACS_INT thisleni = 0;
598 register unsigned int thisindex = 0; 598 register EMACS_INT thisindex = 0;
599 register unsigned int thisindex_byte = 0; 599 register EMACS_INT thisindex_byte = 0;
600 600
601 this = args[argnum]; 601 this = args[argnum];
602 if (!CONSP (this)) 602 if (!CONSP (this))
@@ -606,7 +606,7 @@ concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_speci
606 if (STRINGP (this) && STRINGP (val) 606 if (STRINGP (this) && STRINGP (val)
607 && STRING_MULTIBYTE (this) == some_multibyte) 607 && STRING_MULTIBYTE (this) == some_multibyte)
608 { 608 {
609 int thislen_byte = SBYTES (this); 609 EMACS_INT thislen_byte = SBYTES (this);
610 610
611 memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); 611 memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this));
612 if (! NULL_INTERVAL_P (STRING_INTERVALS (this))) 612 if (! NULL_INTERVAL_P (STRING_INTERVALS (this)))
@@ -713,7 +713,7 @@ concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_speci
713 if (num_textprops > 0) 713 if (num_textprops > 0)
714 { 714 {
715 Lisp_Object props; 715 Lisp_Object props;
716 int last_to_end = -1; 716 EMACS_INT last_to_end = -1;
717 717
718 for (argnum = 0; argnum < num_textprops; argnum++) 718 for (argnum = 0; argnum < num_textprops; argnum++)
719 { 719 {
@@ -938,7 +938,7 @@ string_to_multibyte (Lisp_Object string)
938Lisp_Object 938Lisp_Object
939string_make_unibyte (Lisp_Object string) 939string_make_unibyte (Lisp_Object string)
940{ 940{
941 int nchars; 941 EMACS_INT nchars;
942 unsigned char *buf; 942 unsigned char *buf;
943 Lisp_Object ret; 943 Lisp_Object ret;
944 USE_SAFE_ALLOCA; 944 USE_SAFE_ALLOCA;
@@ -1003,7 +1003,7 @@ If STRING is multibyte and contains a character of charset
1003 1003
1004 if (STRING_MULTIBYTE (string)) 1004 if (STRING_MULTIBYTE (string))
1005 { 1005 {
1006 int bytes = SBYTES (string); 1006 EMACS_INT bytes = SBYTES (string);
1007 unsigned char *str = (unsigned char *) xmalloc (bytes); 1007 unsigned char *str = (unsigned char *) xmalloc (bytes);
1008 1008
1009 memcpy (str, SDATA (string), bytes); 1009 memcpy (str, SDATA (string), bytes);
@@ -1036,7 +1036,7 @@ If you're not sure, whether to use `string-as-multibyte' or
1036 if (! STRING_MULTIBYTE (string)) 1036 if (! STRING_MULTIBYTE (string))
1037 { 1037 {
1038 Lisp_Object new_string; 1038 Lisp_Object new_string;
1039 int nchars, nbytes; 1039 EMACS_INT nchars, nbytes;
1040 1040
1041 parse_str_as_multibyte (SDATA (string), 1041 parse_str_as_multibyte (SDATA (string),
1042 SBYTES (string), 1042 SBYTES (string),
@@ -1138,10 +1138,10 @@ value is a new vector that contains the elements between index FROM
1138 (Lisp_Object string, register Lisp_Object from, Lisp_Object to) 1138 (Lisp_Object string, register Lisp_Object from, Lisp_Object to)
1139{ 1139{
1140 Lisp_Object res; 1140 Lisp_Object res;
1141 int size; 1141 EMACS_INT size;
1142 int size_byte = 0; 1142 EMACS_INT size_byte = 0;
1143 int from_char, to_char; 1143 EMACS_INT from_char, to_char;
1144 int from_byte = 0, to_byte = 0; 1144 EMACS_INT from_byte = 0, to_byte = 0;
1145 1145
1146 CHECK_VECTOR_OR_STRING (string); 1146 CHECK_VECTOR_OR_STRING (string);
1147 CHECK_NUMBER (from); 1147 CHECK_NUMBER (from);
@@ -1206,9 +1206,9 @@ If FROM or TO is negative, it counts from the end.
1206With one argument, just copy STRING without its properties. */) 1206With one argument, just copy STRING without its properties. */)
1207 (Lisp_Object string, register Lisp_Object from, Lisp_Object to) 1207 (Lisp_Object string, register Lisp_Object from, Lisp_Object to)
1208{ 1208{
1209 int size, size_byte; 1209 EMACS_INT size, size_byte;
1210 int from_char, to_char; 1210 EMACS_INT from_char, to_char;
1211 int from_byte, to_byte; 1211 EMACS_INT from_byte, to_byte;
1212 1212
1213 CHECK_STRING (string); 1213 CHECK_STRING (string);
1214 1214
@@ -1256,11 +1256,12 @@ With one argument, just copy STRING without its properties. */)
1256 both in characters and in bytes. */ 1256 both in characters and in bytes. */
1257 1257
1258Lisp_Object 1258Lisp_Object
1259substring_both (Lisp_Object string, int from, int from_byte, int to, int to_byte) 1259substring_both (Lisp_Object string, EMACS_INT from, EMACS_INT from_byte,
1260 EMACS_INT to, EMACS_INT to_byte)
1260{ 1261{
1261 Lisp_Object res; 1262 Lisp_Object res;
1262 int size; 1263 EMACS_INT size;
1263 int size_byte; 1264 EMACS_INT size_byte;
1264 1265
1265 CHECK_VECTOR_OR_STRING (string); 1266 CHECK_VECTOR_OR_STRING (string);
1266 1267
@@ -2150,7 +2151,9 @@ DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0,
2150ARRAY is a vector, string, char-table, or bool-vector. */) 2151ARRAY is a vector, string, char-table, or bool-vector. */)
2151 (Lisp_Object array, Lisp_Object item) 2152 (Lisp_Object array, Lisp_Object item)
2152{ 2153{
2153 register int size, index, charval; 2154 register EMACS_INT size, index;
2155 int charval;
2156
2154 if (VECTORP (array)) 2157 if (VECTORP (array))
2155 { 2158 {
2156 register Lisp_Object *p = XVECTOR (array)->contents; 2159 register Lisp_Object *p = XVECTOR (array)->contents;
@@ -2176,7 +2179,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2176 { 2179 {
2177 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2180 unsigned char str[MAX_MULTIBYTE_LENGTH];
2178 int len = CHAR_STRING (charval, str); 2181 int len = CHAR_STRING (charval, str);
2179 int size_byte = SBYTES (array); 2182 EMACS_INT size_byte = SBYTES (array);
2180 unsigned char *p1 = p, *endp = p + size_byte; 2183 unsigned char *p1 = p, *endp = p + size_byte;
2181 int i; 2184 int i;
2182 2185
@@ -2224,7 +2227,7 @@ DEFUN ("clear-string", Fclear_string, Sclear_string,
2224This makes STRING unibyte and may change its length. */) 2227This makes STRING unibyte and may change its length. */)
2225 (Lisp_Object string) 2228 (Lisp_Object string)
2226{ 2229{
2227 int len; 2230 EMACS_INT len;
2228 CHECK_STRING (string); 2231 CHECK_STRING (string);
2229 len = SBYTES (string); 2232 len = SBYTES (string);
2230 memset (SDATA (string), 0, len); 2233 memset (SDATA (string), 0, len);
@@ -2288,11 +2291,11 @@ usage: (nconc &rest LISTS) */)
2288 LENI is the length of VALS, which should also be the length of SEQ. */ 2291 LENI is the length of VALS, which should also be the length of SEQ. */
2289 2292
2290static void 2293static void
2291mapcar1 (int leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq) 2294mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
2292{ 2295{
2293 register Lisp_Object tail; 2296 register Lisp_Object tail;
2294 Lisp_Object dummy; 2297 Lisp_Object dummy;
2295 register int i; 2298 register EMACS_INT i;
2296 struct gcpro gcpro1, gcpro2, gcpro3; 2299 struct gcpro gcpro1, gcpro2, gcpro3;
2297 2300
2298 if (vals) 2301 if (vals)
@@ -2334,12 +2337,12 @@ mapcar1 (int leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
2334 } 2337 }
2335 else if (STRINGP (seq)) 2338 else if (STRINGP (seq))
2336 { 2339 {
2337 int i_byte; 2340 EMACS_INT i_byte;
2338 2341
2339 for (i = 0, i_byte = 0; i < leni;) 2342 for (i = 0, i_byte = 0; i < leni;)
2340 { 2343 {
2341 int c; 2344 int c;
2342 int i_before = i; 2345 EMACS_INT i_before = i;
2343 2346
2344 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte); 2347 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte);
2345 XSETFASTINT (dummy, c); 2348 XSETFASTINT (dummy, c);
@@ -2371,10 +2374,10 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2371 (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator) 2374 (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator)
2372{ 2375{
2373 Lisp_Object len; 2376 Lisp_Object len;
2374 register int leni; 2377 register EMACS_INT leni;
2375 int nargs; 2378 int nargs;
2376 register Lisp_Object *args; 2379 register Lisp_Object *args;
2377 register int i; 2380 register EMACS_INT i;
2378 struct gcpro gcpro1; 2381 struct gcpro gcpro1;
2379 Lisp_Object ret; 2382 Lisp_Object ret;
2380 USE_SAFE_ALLOCA; 2383 USE_SAFE_ALLOCA;
@@ -2411,7 +2414,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2411 (Lisp_Object function, Lisp_Object sequence) 2414 (Lisp_Object function, Lisp_Object sequence)
2412{ 2415{
2413 register Lisp_Object len; 2416 register Lisp_Object len;
2414 register int leni; 2417 register EMACS_INT leni;
2415 register Lisp_Object *args; 2418 register Lisp_Object *args;
2416 Lisp_Object ret; 2419 Lisp_Object ret;
2417 USE_SAFE_ALLOCA; 2420 USE_SAFE_ALLOCA;
@@ -2437,7 +2440,7 @@ Unlike `mapcar', don't accumulate the results. Return SEQUENCE.
2437SEQUENCE may be a list, a vector, a bool-vector, or a string. */) 2440SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2438 (Lisp_Object function, Lisp_Object sequence) 2441 (Lisp_Object function, Lisp_Object sequence)
2439{ 2442{
2440 register int leni; 2443 register EMACS_INT leni;
2441 2444
2442 leni = XFASTINT (Flength (sequence)); 2445 leni = XFASTINT (Flength (sequence));
2443 if (CHAR_TABLE_P (sequence)) 2446 if (CHAR_TABLE_P (sequence))
@@ -2961,8 +2964,9 @@ static const short base64_char_to_value[128] =
2961 base64 characters. */ 2964 base64 characters. */
2962 2965
2963 2966
2964static int base64_encode_1 (const char *, char *, int, int, int); 2967static EMACS_INT base64_encode_1 (const char *, char *, EMACS_INT, int, int);
2965static int base64_decode_1 (const char *, char *, int, int, int *); 2968static EMACS_INT base64_decode_1 (const char *, char *, EMACS_INT, int,
2969 EMACS_INT *);
2966 2970
2967DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2971DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
2968 2, 3, "r", 2972 2, 3, "r",
@@ -2973,9 +2977,9 @@ into shorter lines. */)
2973 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break) 2977 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break)
2974{ 2978{
2975 char *encoded; 2979 char *encoded;
2976 int allength, length; 2980 EMACS_INT allength, length;
2977 int ibeg, iend, encoded_length; 2981 EMACS_INT ibeg, iend, encoded_length;
2978 int old_pos = PT; 2982 EMACS_INT old_pos = PT;
2979 USE_SAFE_ALLOCA; 2983 USE_SAFE_ALLOCA;
2980 2984
2981 validate_region (&beg, &end); 2985 validate_region (&beg, &end);
@@ -3031,7 +3035,7 @@ Optional second argument NO-LINE-BREAK means do not break long lines
3031into shorter lines. */) 3035into shorter lines. */)
3032 (Lisp_Object string, Lisp_Object no_line_break) 3036 (Lisp_Object string, Lisp_Object no_line_break)
3033{ 3037{
3034 int allength, length, encoded_length; 3038 EMACS_INT allength, length, encoded_length;
3035 char *encoded; 3039 char *encoded;
3036 Lisp_Object encoded_string; 3040 Lisp_Object encoded_string;
3037 USE_SAFE_ALLOCA; 3041 USE_SAFE_ALLOCA;
@@ -3067,10 +3071,12 @@ into shorter lines. */)
3067 return encoded_string; 3071 return encoded_string;
3068} 3072}
3069 3073
3070static int 3074static EMACS_INT
3071base64_encode_1 (const char *from, char *to, int length, int line_break, int multibyte) 3075base64_encode_1 (const char *from, char *to, EMACS_INT length,
3076 int line_break, int multibyte)
3072{ 3077{
3073 int counter = 0, i = 0; 3078 int counter = 0;
3079 EMACS_INT i = 0;
3074 char *e = to; 3080 char *e = to;
3075 int c; 3081 int c;
3076 unsigned int value; 3082 unsigned int value;
@@ -3169,11 +3175,11 @@ Return the length of the decoded text.
3169If the region can't be decoded, signal an error and don't modify the buffer. */) 3175If the region can't be decoded, signal an error and don't modify the buffer. */)
3170 (Lisp_Object beg, Lisp_Object end) 3176 (Lisp_Object beg, Lisp_Object end)
3171{ 3177{
3172 int ibeg, iend, length, allength; 3178 EMACS_INT ibeg, iend, length, allength;
3173 char *decoded; 3179 char *decoded;
3174 int old_pos = PT; 3180 EMACS_INT old_pos = PT;
3175 int decoded_length; 3181 EMACS_INT decoded_length;
3176 int inserted_chars; 3182 EMACS_INT inserted_chars;
3177 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 3183 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
3178 USE_SAFE_ALLOCA; 3184 USE_SAFE_ALLOCA;
3179 3185
@@ -3230,7 +3236,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3230 (Lisp_Object string) 3236 (Lisp_Object string)
3231{ 3237{
3232 char *decoded; 3238 char *decoded;
3233 int length, decoded_length; 3239 EMACS_INT length, decoded_length;
3234 Lisp_Object decoded_string; 3240 Lisp_Object decoded_string;
3235 USE_SAFE_ALLOCA; 3241 USE_SAFE_ALLOCA;
3236 3242
@@ -3262,14 +3268,15 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3262 form. If NCHARS_RETRUN is not NULL, store the number of produced 3268 form. If NCHARS_RETRUN is not NULL, store the number of produced
3263 characters in *NCHARS_RETURN. */ 3269 characters in *NCHARS_RETURN. */
3264 3270
3265static int 3271static EMACS_INT
3266base64_decode_1 (const char *from, char *to, int length, int multibyte, int *nchars_return) 3272base64_decode_1 (const char *from, char *to, EMACS_INT length,
3273 int multibyte, EMACS_INT *nchars_return)
3267{ 3274{
3268 int i = 0; 3275 EMACS_INT i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3269 char *e = to; 3276 char *e = to;
3270 unsigned char c; 3277 unsigned char c;
3271 unsigned long value; 3278 unsigned long value;
3272 int nchars = 0; 3279 EMACS_INT nchars = 0;
3273 3280
3274 while (1) 3281 while (1)
3275 { 3282 {
@@ -4575,13 +4582,13 @@ guesswork fails. Normally, an error is signaled in such case. */)
4575 unsigned char digest[16]; 4582 unsigned char digest[16];
4576 unsigned char value[33]; 4583 unsigned char value[33];
4577 int i; 4584 int i;
4578 int size; 4585 EMACS_INT size;
4579 int size_byte = 0; 4586 EMACS_INT size_byte = 0;
4580 int start_char = 0, end_char = 0; 4587 EMACS_INT start_char = 0, end_char = 0;
4581 int start_byte = 0, end_byte = 0; 4588 EMACS_INT start_byte = 0, end_byte = 0;
4582 register int b, e; 4589 register EMACS_INT b, e;
4583 register struct buffer *bp; 4590 register struct buffer *bp;
4584 int temp; 4591 EMACS_INT temp;
4585 4592
4586 if (STRINGP (object)) 4593 if (STRINGP (object))
4587 { 4594 {
diff --git a/src/font.c b/src/font.c
index ae7211e92fe..dee55d1e976 100644
--- a/src/font.c
+++ b/src/font.c
@@ -237,7 +237,7 @@ font_intern_prop (const char *str, int len, int force_symbol)
237 int i; 237 int i;
238 Lisp_Object tem; 238 Lisp_Object tem;
239 Lisp_Object obarray; 239 Lisp_Object obarray;
240 int nbytes, nchars; 240 EMACS_INT nbytes, nchars;
241 241
242 if (len == 1 && *str == '*') 242 if (len == 1 && *str == '*')
243 return Qnil; 243 return Qnil;
diff --git a/src/frame.c b/src/frame.c
index 93a6e898c9b..04cc1ca07da 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2649,6 +2649,28 @@ If FRAME is omitted, the selected frame is used. */)
2649#endif 2649#endif
2650 return make_number (FRAME_COLS (f)); 2650 return make_number (FRAME_COLS (f));
2651} 2651}
2652
2653DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width,
2654 Stool_bar_pixel_width, 0, 1, 0,
2655 doc: /* Return width in pixels of FRAME's tool bar.
2656The result is greater than zero only when the tool bar is on the left
2657or right side of FRAME. If FRAME is omitted, the selected frame is
2658used. */)
2659 (Lisp_Object frame)
2660{
2661 struct frame *f;
2662
2663 if (NILP (frame))
2664 frame = selected_frame;
2665 CHECK_FRAME (frame);
2666 f = XFRAME (frame);
2667
2668#ifdef FRAME_TOOLBAR_WIDTH
2669 if (FRAME_WINDOW_P (f))
2670 return make_number (FRAME_TOOLBAR_WIDTH (f));
2671#endif
2672 return make_number (0);
2673}
2652 2674
2653DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0, 2675DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
2654 doc: /* Specify that the frame FRAME has LINES lines. 2676 doc: /* Specify that the frame FRAME has LINES lines.
@@ -4596,6 +4618,7 @@ automatically. See also `mouse-autoselect-window'. */);
4596 defsubr (&Sframe_char_width); 4618 defsubr (&Sframe_char_width);
4597 defsubr (&Sframe_pixel_height); 4619 defsubr (&Sframe_pixel_height);
4598 defsubr (&Sframe_pixel_width); 4620 defsubr (&Sframe_pixel_width);
4621 defsubr (&Stool_bar_pixel_width);
4599 defsubr (&Sset_frame_height); 4622 defsubr (&Sset_frame_height);
4600 defsubr (&Sset_frame_width); 4623 defsubr (&Sset_frame_width);
4601 defsubr (&Sset_frame_size); 4624 defsubr (&Sset_frame_size);
diff --git a/src/frame.h b/src/frame.h
index 6b307c7c3b1..e66fd9341c7 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -310,7 +310,7 @@ struct frame
310 /* Canonical X unit. Width of default font, in pixels. */ 310 /* Canonical X unit. Width of default font, in pixels. */
311 int column_width; 311 int column_width;
312 312
313 /* Widht of space glyph of default font, in pixels. */ 313 /* Width of space glyph of default font, in pixels. */
314 int space_width; 314 int space_width;
315 315
316 /* Canonical Y unit. Height of a line, in pixels. */ 316 /* Canonical Y unit. Height of a line, in pixels. */
diff --git a/src/ftfont.c b/src/ftfont.c
index b99e50ca3ff..97bf265a84c 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1632,38 +1632,70 @@ ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring,
1632static int 1632static int
1633ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec) 1633ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec)
1634{ 1634{
1635#define FEATURE_NONE(IDX) (! spec->features[IDX])
1636
1637#define FEATURE_ANY(IDX) \
1638 (spec->features[IDX] \
1639 && spec->features[IDX][0] == 0xFFFFFFFF && spec->features[IDX][1] == 0)
1640
1635 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; 1641 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font;
1636 OTF *otf = flt_font_ft->otf; 1642 OTF *otf = flt_font_ft->otf;
1637 OTF_Tag *tags; 1643 OTF_Tag *tags;
1638 int i, n, negative; 1644 int i, n, negative;
1639 1645
1646 if (FEATURE_ANY (0) && FEATURE_ANY (1))
1647 /* Return 1 iff any of GSUB or GPOS support the script (and language). */
1648 return (otf
1649 && (OTF_check_features (otf, 0, spec->script, spec->langsys,
1650 NULL, 0) > 0
1651 || OTF_check_features (otf, 1, spec->script, spec->langsys,
1652 NULL, 0) > 0));
1653
1640 for (i = 0; i < 2; i++) 1654 for (i = 0; i < 2; i++)
1641 { 1655 if (! FEATURE_ANY (i))
1642 if (! spec->features[i]) 1656 {
1643 continue; 1657 if (FEATURE_NONE (i))
1644 for (n = 0; spec->features[i][n]; n++); 1658 {
1645 tags = alloca (sizeof (OTF_Tag) * n); 1659 if (otf
1646 for (n = 0, negative = 0; spec->features[i][n]; n++) 1660 && OTF_check_features (otf, i == 0, spec->script, spec->langsys,
1647 { 1661 NULL, 0) > 0)
1648 if (spec->features[i][n] == 0xFFFFFFFF) 1662 return 0;
1649 negative = 1; 1663 continue;
1650 else if (negative) 1664 }
1651 tags[n - 1] = spec->features[i][n] | 0x80000000; 1665 if (spec->features[i][0] == 0xFFFFFFFF)
1652 else 1666 {
1653 tags[n] = spec->features[i][n]; 1667 if (! otf
1654 } 1668 || OTF_check_features (otf, i == 0, spec->script, spec->langsys,
1669 NULL, 0) <= 0)
1670 continue;
1671 }
1672 else if (! otf)
1673 return 0;
1674 for (n = 1; spec->features[i][n]; n++);
1675 tags = alloca (sizeof (OTF_Tag) * n);
1676 for (n = 0, negative = 0; spec->features[i][n]; n++)
1677 {
1678 if (spec->features[i][n] == 0xFFFFFFFF)
1679 negative = 1;
1680 else if (negative)
1681 tags[n - 1] = spec->features[i][n] | 0x80000000;
1682 else
1683 tags[n] = spec->features[i][n];
1684 }
1655#ifdef M17N_FLT_USE_NEW_FEATURE 1685#ifdef M17N_FLT_USE_NEW_FEATURE
1656 if (OTF_check_features (otf, i == 0, spec->script, spec->langsys, 1686 if (OTF_check_features (otf, i == 0, spec->script, spec->langsys,
1657 tags, n - negative) != 1) 1687 tags, n - negative) != 1)
1658 return 0; 1688 return 0;
1659#else /* not M17N_FLT_USE_NEW_FEATURE */ 1689#else /* not M17N_FLT_USE_NEW_FEATURE */
1660 if (n - negative > 0 1690 if (n - negative > 0
1661 && OTF_check_features (otf, i == 0, spec->script, spec->langsys, 1691 && OTF_check_features (otf, i == 0, spec->script, spec->langsys,
1662 tags, n - negative) != 1) 1692 tags, n - negative) != 1)
1663 return 0; 1693 return 0;
1664#endif /* not M17N_FLT_USE_NEW_FEATURE */ 1694#endif /* not M17N_FLT_USE_NEW_FEATURE */
1665 } 1695 }
1666 return 1; 1696 return 1;
1697#undef FEATURE_NONE
1698#undef FEATURE_ANY
1667} 1699}
1668 1700
1669#define DEVICE_DELTA(table, size) \ 1701#define DEVICE_DELTA(table, size) \
diff --git a/src/gnutls.c b/src/gnutls.c
new file mode 100644
index 00000000000..37b4341d184
--- /dev/null
+++ b/src/gnutls.c
@@ -0,0 +1,539 @@
1/* GnuTLS glue for GNU Emacs.
2 Copyright (C) 2010 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#include <config.h>
20#include <errno.h>
21#include <setjmp.h>
22
23#include "lisp.h"
24#include "process.h"
25
26#ifdef HAVE_GNUTLS
27#include <gnutls/gnutls.h>
28
29Lisp_Object Qgnutls_code;
30Lisp_Object Qgnutls_anon, Qgnutls_x509pki;
31Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again,
32 Qgnutls_e_invalid_session, Qgnutls_e_not_ready_for_handshake;
33int global_initialized;
34
35void
36emacs_gnutls_handshake (struct Lisp_Process *proc)
37{
38 gnutls_session_t state = proc->gnutls_state;
39 int ret;
40
41 if (proc->gnutls_initstage < GNUTLS_STAGE_HANDSHAKE_CANDO)
42 return;
43
44 if (proc->gnutls_initstage < GNUTLS_STAGE_TRANSPORT_POINTERS_SET)
45 {
46 gnutls_transport_set_ptr2 (state,
47 (gnutls_transport_ptr_t) (long) proc->infd,
48 (gnutls_transport_ptr_t) (long) proc->outfd);
49
50 proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET;
51 }
52
53 ret = gnutls_handshake (state);
54 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
55
56 if (ret == GNUTLS_E_SUCCESS)
57 {
58 /* here we're finally done. */
59 proc->gnutls_initstage = GNUTLS_STAGE_READY;
60 }
61}
62
63int
64emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf,
65 unsigned int nbyte)
66{
67 register int rtnval, bytes_written;
68 gnutls_session_t state = proc->gnutls_state;
69
70 if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
71 return -1;
72
73 bytes_written = 0;
74
75 while (nbyte > 0)
76 {
77 rtnval = gnutls_write (state, buf, nbyte);
78
79 if (rtnval == -1)
80 {
81 if (errno == EINTR)
82 continue;
83 else
84 return (bytes_written ? bytes_written : -1);
85 }
86
87 buf += rtnval;
88 nbyte -= rtnval;
89 bytes_written += rtnval;
90 }
91 fsync (STDOUT_FILENO);
92
93 return (bytes_written);
94}
95
96int
97emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf,
98 unsigned int nbyte)
99{
100 register int rtnval;
101 gnutls_session_t state = proc->gnutls_state;
102
103 if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
104 {
105 emacs_gnutls_handshake (proc);
106 return -1;
107 }
108
109 rtnval = gnutls_read (state, buf, nbyte);
110 if (rtnval >= 0)
111 return rtnval;
112 else
113 return 0;
114}
115
116/* convert an integer error to a Lisp_Object; it will be either a
117 known symbol like `gnutls_e_interrupted' and `gnutls_e_again' or
118 simply the integer value of the error. GNUTLS_E_SUCCESS is mapped
119 to Qt. */
120Lisp_Object gnutls_make_error (int error)
121{
122 switch (error)
123 {
124 case GNUTLS_E_SUCCESS:
125 return Qt;
126 case GNUTLS_E_AGAIN:
127 return Qgnutls_e_again;
128 case GNUTLS_E_INTERRUPTED:
129 return Qgnutls_e_interrupted;
130 case GNUTLS_E_INVALID_SESSION:
131 return Qgnutls_e_invalid_session;
132 }
133
134 return make_number (error);
135}
136
137DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0,
138 doc: /* Return the GnuTLS init stage of PROCESS.
139See also `gnutls-boot'. */)
140 (Lisp_Object proc)
141{
142 CHECK_PROCESS (proc);
143
144 return make_number (GNUTLS_INITSTAGE (proc));
145}
146
147DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0,
148 doc: /* Returns t if ERROR (as generated by gnutls_make_error)
149indicates a GnuTLS problem. */)
150 (Lisp_Object error)
151{
152 if (EQ (error, Qt)) return Qnil;
153
154 return Qt;
155}
156
157DEFUN ("gnutls-error-fatalp", Fgnutls_error_fatalp, Sgnutls_error_fatalp, 1, 1, 0,
158 doc: /* Checks if ERROR is fatal.
159ERROR is an integer or a symbol with an integer `gnutls-code' property. */)
160 (Lisp_Object err)
161{
162 Lisp_Object code;
163
164 if (EQ (err, Qt)) return Qnil;
165
166 if (SYMBOLP (err))
167 {
168 code = Fget (err, Qgnutls_code);
169 if (NUMBERP (code))
170 {
171 err = code;
172 }
173 else
174 {
175 error ("Symbol has no numeric gnutls-code property");
176 }
177 }
178
179 if (!NUMBERP (err))
180 error ("Not an error symbol or code");
181
182 if (0 == gnutls_error_is_fatal (XINT (err)))
183 return Qnil;
184
185 return Qt;
186}
187
188DEFUN ("gnutls-error-string", Fgnutls_error_string, Sgnutls_error_string, 1, 1, 0,
189 doc: /* Returns a description of ERROR.
190ERROR is an integer or a symbol with an integer `gnutls-code' property. */)
191 (Lisp_Object err)
192{
193 Lisp_Object code;
194
195 if (EQ (err, Qt)) return build_string ("Not an error");
196
197 if (SYMBOLP (err))
198 {
199 code = Fget (err, Qgnutls_code);
200 if (NUMBERP (code))
201 {
202 err = code;
203 }
204 else
205 {
206 return build_string ("Symbol has no numeric gnutls-code property");
207 }
208 }
209
210 if (!NUMBERP (err))
211 return build_string ("Not an error symbol or code");
212
213 return build_string (gnutls_strerror (XINT (err)));
214}
215
216DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0,
217 doc: /* Deallocate GNU TLS resources associated with PROCESS.
218See also `gnutls-init'. */)
219 (Lisp_Object proc)
220{
221 gnutls_session_t state;
222
223 CHECK_PROCESS (proc);
224 state = XPROCESS (proc)->gnutls_state;
225
226 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
227 {
228 gnutls_deinit (state);
229 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1;
230 }
231
232 return Qt;
233}
234
235/* Initializes global GNU TLS state to defaults.
236Call `gnutls-global-deinit' when GNU TLS usage is no longer needed.
237Returns zero on success. */
238Lisp_Object gnutls_emacs_global_init (void)
239{
240 int ret = GNUTLS_E_SUCCESS;
241
242 if (!global_initialized)
243 ret = gnutls_global_init ();
244
245 global_initialized = 1;
246
247 return gnutls_make_error (ret);
248}
249
250/* Deinitializes global GNU TLS state.
251See also `gnutls-global-init'. */
252Lisp_Object gnutls_emacs_global_deinit (void)
253{
254 if (global_initialized)
255 gnutls_global_deinit ();
256
257 global_initialized = 0;
258
259 return gnutls_make_error (GNUTLS_E_SUCCESS);
260}
261
262static void gnutls_log_function (int level, const char* string)
263{
264 message("gnutls.c: [%d] %s", level, string);
265}
266
267DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 7, 0,
268 doc: /* Initializes client-mode GnuTLS for process PROC.
269Currently only client mode is supported. Returns a success/failure
270value you can check with `gnutls-errorp'.
271
272PRIORITY_STRING is a string describing the priority.
273TYPE is either `gnutls-anon' or `gnutls-x509pki'.
274TRUSTFILE is a PEM encoded trust file for `gnutls-x509pki'.
275KEYFILE is ... for `gnutls-x509pki' (TODO).
276CALLBACK is ... for `gnutls-x509pki' (TODO).
277LOGLEVEL is the debug level requested from GnuTLS, try 4.
278
279LOGLEVEL will be set for this process AND globally for GnuTLS. So if
280you set it higher or lower at any point, it affects global debugging.
281
282Note that the priority is set on the client. The server does not use
283the protocols's priority except for disabling protocols that were not
284specified.
285
286Processes must be initialized with this function before other GNU TLS
287functions are used. This function allocates resources which can only
288be deallocated by calling `gnutls-deinit' or by calling it again.
289
290Each authentication type may need additional information in order to
291work. For X.509 PKI (`gnutls-x509pki'), you need TRUSTFILE and
292KEYFILE and optionally CALLBACK. */)
293 (Lisp_Object proc, Lisp_Object priority_string, Lisp_Object type,
294 Lisp_Object trustfile, Lisp_Object keyfile, Lisp_Object callback,
295 Lisp_Object loglevel)
296{
297 int ret = GNUTLS_E_SUCCESS;
298
299 int max_log_level = 0;
300
301 /* TODO: GNUTLS_X509_FMT_DER is also an option. */
302 int file_format = GNUTLS_X509_FMT_PEM;
303
304 gnutls_session_t state;
305 gnutls_certificate_credentials_t x509_cred;
306 gnutls_anon_client_credentials_t anon_cred;
307 Lisp_Object global_init;
308
309 CHECK_PROCESS (proc);
310 CHECK_SYMBOL (type);
311 CHECK_STRING (priority_string);
312
313 state = XPROCESS (proc)->gnutls_state;
314 XPROCESS (proc)->gnutls_p = 1;
315
316 if (NUMBERP (loglevel))
317 {
318 gnutls_global_set_log_function (gnutls_log_function);
319 gnutls_global_set_log_level (XINT (loglevel));
320 max_log_level = XINT (loglevel);
321 XPROCESS (proc)->gnutls_log_level = max_log_level;
322 }
323
324 /* always initialize globals. */
325 global_init = gnutls_emacs_global_init ();
326 if (! NILP (Fgnutls_errorp (global_init)))
327 return global_init;
328
329 /* deinit and free resources. */
330 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC)
331 {
332 GNUTLS_LOG (1, max_log_level, "deallocating credentials");
333
334 if (EQ (type, Qgnutls_x509pki))
335 {
336 GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials");
337 x509_cred = XPROCESS (proc)->gnutls_x509_cred;
338 gnutls_certificate_free_credentials (x509_cred);
339 }
340 else if (EQ (type, Qgnutls_anon))
341 {
342 GNUTLS_LOG (2, max_log_level, "deallocating anon credentials");
343 anon_cred = XPROCESS (proc)->gnutls_anon_cred;
344 gnutls_anon_free_client_credentials (anon_cred);
345 }
346 else
347 {
348 error ("unknown credential type");
349 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
350 }
351
352 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
353 {
354 GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials");
355 Fgnutls_deinit (proc);
356 }
357 }
358
359 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY;
360
361 GNUTLS_LOG (1, max_log_level, "allocating credentials");
362
363 if (EQ (type, Qgnutls_x509pki))
364 {
365 GNUTLS_LOG (2, max_log_level, "allocating x509 credentials");
366 x509_cred = XPROCESS (proc)->gnutls_x509_cred;
367 if (gnutls_certificate_allocate_credentials (&x509_cred) < 0)
368 memory_full ();
369 }
370 else if (EQ (type, Qgnutls_anon))
371 {
372 GNUTLS_LOG (2, max_log_level, "allocating anon credentials");
373 anon_cred = XPROCESS (proc)->gnutls_anon_cred;
374 if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0)
375 memory_full ();
376 }
377 else
378 {
379 error ("unknown credential type");
380 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
381 }
382
383 if (ret < GNUTLS_E_SUCCESS)
384 return gnutls_make_error (ret);
385
386 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC;
387
388 if (EQ (type, Qgnutls_x509pki))
389 {
390 if (STRINGP (trustfile))
391 {
392 GNUTLS_LOG (1, max_log_level, "setting the trustfile");
393 ret = gnutls_certificate_set_x509_trust_file
394 (x509_cred,
395 SDATA (trustfile),
396 file_format);
397
398 if (ret < GNUTLS_E_SUCCESS)
399 return gnutls_make_error (ret);
400 }
401
402 if (STRINGP (keyfile))
403 {
404 GNUTLS_LOG (1, max_log_level, "setting the keyfile");
405 ret = gnutls_certificate_set_x509_crl_file
406 (x509_cred,
407 SDATA (keyfile),
408 file_format);
409
410 if (ret < GNUTLS_E_SUCCESS)
411 return gnutls_make_error (ret);
412 }
413 }
414
415 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES;
416
417 GNUTLS_LOG (1, max_log_level, "gnutls_init");
418
419 ret = gnutls_init (&state, GNUTLS_CLIENT);
420
421 if (ret < GNUTLS_E_SUCCESS)
422 return gnutls_make_error (ret);
423
424 XPROCESS (proc)->gnutls_state = state;
425
426 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT;
427
428 GNUTLS_LOG (1, max_log_level, "setting the priority string");
429
430 ret = gnutls_priority_set_direct(state,
431 (char*) SDATA (priority_string),
432 NULL);
433
434 if (ret < GNUTLS_E_SUCCESS)
435 return gnutls_make_error (ret);
436
437 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY;
438
439 if (EQ (type, Qgnutls_x509pki))
440 {
441 ret = gnutls_cred_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred);
442 }
443 else if (EQ (type, Qgnutls_anon))
444 {
445 ret = gnutls_cred_set (state, GNUTLS_CRD_ANON, anon_cred);
446 }
447 else
448 {
449 error ("unknown credential type");
450 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
451 }
452
453 if (ret < GNUTLS_E_SUCCESS)
454 return gnutls_make_error (ret);
455
456 XPROCESS (proc)->gnutls_anon_cred = anon_cred;
457 XPROCESS (proc)->gnutls_x509_cred = x509_cred;
458 XPROCESS (proc)->gnutls_cred_type = type;
459
460 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET;
461
462 emacs_gnutls_handshake (XPROCESS (proc));
463
464 return gnutls_make_error (GNUTLS_E_SUCCESS);
465}
466
467DEFUN ("gnutls-bye", Fgnutls_bye,
468 Sgnutls_bye, 2, 2, 0,
469 doc: /* Terminate current GNU TLS connection for PROCESS.
470The connection should have been initiated using `gnutls-handshake'.
471
472If CONT is not nil the TLS connection gets terminated and further
473receives and sends will be disallowed. If the return value is zero you
474may continue using the connection. If CONT is nil, GnuTLS actually
475sends an alert containing a close request and waits for the peer to
476reply with the same message. In order to reuse the connection you
477should wait for an EOF from the peer.
478
479This function may also return `gnutls-e-again', or
480`gnutls-e-interrupted'. */)
481 (Lisp_Object proc, Lisp_Object cont)
482{
483 gnutls_session_t state;
484 int ret;
485
486 CHECK_PROCESS (proc);
487
488 state = XPROCESS (proc)->gnutls_state;
489
490 ret = gnutls_bye (state,
491 NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR);
492
493 return gnutls_make_error (ret);
494}
495
496void
497syms_of_gnutls (void)
498{
499 global_initialized = 0;
500
501 Qgnutls_code = intern_c_string ("gnutls-code");
502 staticpro (&Qgnutls_code);
503
504 Qgnutls_anon = intern_c_string ("gnutls-anon");
505 staticpro (&Qgnutls_anon);
506
507 Qgnutls_x509pki = intern_c_string ("gnutls-x509pki");
508 staticpro (&Qgnutls_x509pki);
509
510 Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted");
511 staticpro (&Qgnutls_e_interrupted);
512 Fput (Qgnutls_e_interrupted, Qgnutls_code,
513 make_number (GNUTLS_E_INTERRUPTED));
514
515 Qgnutls_e_again = intern_c_string ("gnutls-e-again");
516 staticpro (&Qgnutls_e_again);
517 Fput (Qgnutls_e_again, Qgnutls_code,
518 make_number (GNUTLS_E_AGAIN));
519
520 Qgnutls_e_invalid_session = intern_c_string ("gnutls-e-invalid-session");
521 staticpro (&Qgnutls_e_invalid_session);
522 Fput (Qgnutls_e_invalid_session, Qgnutls_code,
523 make_number (GNUTLS_E_INVALID_SESSION));
524
525 Qgnutls_e_not_ready_for_handshake =
526 intern_c_string ("gnutls-e-not-ready-for-handshake");
527 staticpro (&Qgnutls_e_not_ready_for_handshake);
528 Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code,
529 make_number (GNUTLS_E_APPLICATION_ERROR_MIN));
530
531 defsubr (&Sgnutls_get_initstage);
532 defsubr (&Sgnutls_errorp);
533 defsubr (&Sgnutls_error_fatalp);
534 defsubr (&Sgnutls_error_string);
535 defsubr (&Sgnutls_boot);
536 defsubr (&Sgnutls_deinit);
537 defsubr (&Sgnutls_bye);
538}
539#endif
diff --git a/src/gnutls.h b/src/gnutls.h
new file mode 100644
index 00000000000..bcf9776963f
--- /dev/null
+++ b/src/gnutls.h
@@ -0,0 +1,62 @@
1/* GnuTLS glue for GNU Emacs.
2 Copyright (C) 2010 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 EMACS_GNUTLS_DEFINED
20#define EMACS_GNUTLS_DEFINED
21
22#ifdef HAVE_GNUTLS
23#include <gnutls/gnutls.h>
24
25typedef enum
26{
27 /* Initialization stages. */
28 GNUTLS_STAGE_EMPTY = 0,
29 GNUTLS_STAGE_CRED_ALLOC,
30 GNUTLS_STAGE_FILES,
31 GNUTLS_STAGE_INIT,
32 GNUTLS_STAGE_PRIORITY,
33 GNUTLS_STAGE_CRED_SET,
34
35 /* Handshake stages. */
36 GNUTLS_STAGE_HANDSHAKE_CANDO = GNUTLS_STAGE_CRED_SET,
37 GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
38 GNUTLS_STAGE_HANDSHAKE_TRIED,
39
40 GNUTLS_STAGE_READY,
41} gnutls_initstage_t;
42
43#define GNUTLS_EMACS_ERROR_INVALID_TYPE GNUTLS_E_APPLICATION_ERROR_MIN
44
45#define GNUTLS_INITSTAGE(proc) (XPROCESS (proc)->gnutls_initstage)
46
47#define GNUTLS_PROCESS_USABLE(proc) (GNUTLS_INITSTAGE(proc) >= GNUTLS_STAGE_READY)
48
49#define GNUTLS_LOG(level, max, string) if (level <= max) { gnutls_log_function (level, "(Emacs) " string); }
50
51int
52emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf,
53 unsigned int nbyte);
54int
55emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf,
56 unsigned int nbyte);
57
58extern void syms_of_gnutls (void);
59
60#endif
61
62#endif
diff --git a/src/gtkutil.c b/src/gtkutil.c
index dbd48eb5272..f82be62965d 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3716,6 +3716,8 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
3716 GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton)); 3716 GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton));
3717 GtkImageType store_type = gtk_image_get_storage_type (wimage); 3717 GtkImageType store_type = gtk_image_get_storage_type (wimage);
3718 3718
3719 g_object_set (G_OBJECT (settings), "gtk-menu-images", TRUE, NULL);
3720
3719 if (store_type == GTK_IMAGE_STOCK) 3721 if (store_type == GTK_IMAGE_STOCK)
3720 { 3722 {
3721 gchar *stock_id; 3723 gchar *stock_id;
@@ -3974,6 +3976,8 @@ xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
3974 3976
3975 if (into_hbox) 3977 if (into_hbox)
3976 { 3978 {
3979 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
3980 GTK_POS_TOP);
3977 gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget, 3981 gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget,
3978 FALSE, FALSE, 0); 3982 FALSE, FALSE, 0);
3979 3983
@@ -3986,6 +3990,8 @@ xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
3986 else 3990 else
3987 { 3991 {
3988 int vbox_pos = x->menubar_widget ? 1 : 0; 3992 int vbox_pos = x->menubar_widget ? 1 : 0;
3993 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
3994 GTK_POS_LEFT);
3989 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, 3995 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget,
3990 FALSE, FALSE, 0); 3996 FALSE, FALSE, 0);
3991 3997
diff --git a/src/image.c b/src/image.c
index 499cbf298c1..3c74c516d3f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8626,7 +8626,7 @@ of `image-library-alist', which see). */)
8626#if defined (HAVE_IMAGEMAGICK) 8626#if defined (HAVE_IMAGEMAGICK)
8627 if (EQ (type, Qimagemagick)) 8627 if (EQ (type, Qimagemagick))
8628 { 8628 {
8629 /* MagickWandGenesis() initalizes the imagemagick library. */ 8629 /* MagickWandGenesis() initializes the imagemagick library. */
8630 MagickWandGenesis (); 8630 MagickWandGenesis ();
8631 return CHECK_LIB_AVAILABLE (&imagemagick_type, init_imagemagick_functions, 8631 return CHECK_LIB_AVAILABLE (&imagemagick_type, init_imagemagick_functions,
8632 libraries); 8632 libraries);
diff --git a/src/indent.c b/src/indent.c
index 970904cba7b..affcc222f0b 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -865,7 +865,7 @@ following any initial whitespace. */)
865 (void) 865 (void)
866{ 866{
867 Lisp_Object val; 867 Lisp_Object val;
868 int opoint = PT, opoint_byte = PT_BYTE; 868 EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
869 869
870 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); 870 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
871 871
@@ -964,10 +964,10 @@ position_indentation (register int pos_byte)
964 preceding line. */ 964 preceding line. */
965 965
966int 966int
967indented_beyond_p (int pos, int pos_byte, double column) 967indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, double column)
968{ 968{
969 double val; 969 double val;
970 int opoint = PT, opoint_byte = PT_BYTE; 970 EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
971 971
972 SET_PT_BOTH (pos, pos_byte); 972 SET_PT_BOTH (pos, pos_byte);
973 while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n') 973 while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n')
@@ -1254,7 +1254,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1254 to be changed here. */ 1254 to be changed here. */
1255 { 1255 {
1256 unsigned char *ovstr; 1256 unsigned char *ovstr;
1257 int ovlen = overlay_strings (pos, win, &ovstr); 1257 EMACS_INT ovlen = overlay_strings (pos, win, &ovstr);
1258 hpos += ((multibyte && ovlen > 0) 1258 hpos += ((multibyte && ovlen > 0)
1259 ? strwidth (ovstr, ovlen) : ovlen); 1259 ? strwidth (ovstr, ovlen) : ovlen);
1260 } 1260 }
@@ -1448,7 +1448,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1448 the text character-by-character. */ 1448 the text character-by-character. */
1449 if (current_buffer->width_run_cache && pos >= next_width_run) 1449 if (current_buffer->width_run_cache && pos >= next_width_run)
1450 { 1450 {
1451 int run_end; 1451 EMACS_INT run_end;
1452 int common_width 1452 int common_width
1453 = region_cache_forward (current_buffer, 1453 = region_cache_forward (current_buffer,
1454 current_buffer->width_run_cache, 1454 current_buffer->width_run_cache,
@@ -1459,7 +1459,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1459 want to skip over it for some other reason. */ 1459 want to skip over it for some other reason. */
1460 if (common_width != 0) 1460 if (common_width != 0)
1461 { 1461 {
1462 int run_end_hpos; 1462 EMACS_INT run_end_hpos;
1463 1463
1464 /* Don't go past the final buffer posn the user 1464 /* Don't go past the final buffer posn the user
1465 requested. */ 1465 requested. */
diff --git a/src/insdel.c b/src/insdel.c
index 2ccc0b8eaac..abe6f350585 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -2051,14 +2051,15 @@ prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end,
2051 2051
2052 /* If `select-active-regions' is non-nil, save the region text. */ 2052 /* If `select-active-regions' is non-nil, save the region text. */
2053 if (!NILP (current_buffer->mark_active) 2053 if (!NILP (current_buffer->mark_active)
2054 && XMARKER (current_buffer->mark)->buffer
2054 && NILP (Vsaved_region_selection) 2055 && NILP (Vsaved_region_selection)
2055 && (EQ (Vselect_active_regions, Qonly) 2056 && (EQ (Vselect_active_regions, Qonly)
2056 ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) 2057 ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
2057 : (!NILP (Vselect_active_regions) 2058 : (!NILP (Vselect_active_regions)
2058 && !NILP (Vtransient_mark_mode)))) 2059 && !NILP (Vtransient_mark_mode))))
2059 { 2060 {
2060 int b = XINT (Fmarker_position (current_buffer->mark)); 2061 EMACS_INT b = XMARKER (current_buffer->mark)->charpos;
2061 int e = XINT (make_number (PT)); 2062 EMACS_INT e = PT;
2062 if (b < e) 2063 if (b < e)
2063 Vsaved_region_selection = make_buffer_string (b, e, 0); 2064 Vsaved_region_selection = make_buffer_string (b, e, 0);
2064 else if (b > e) 2065 else if (b > e)
diff --git a/src/intervals.c b/src/intervals.c
index 86cbe1effcc..5e08e13d23b 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -222,7 +222,8 @@ traverse_intervals_noorder (INTERVAL tree, void (*function) (INTERVAL, Lisp_Obje
222 Pass FUNCTION two args: an interval, and ARG. */ 222 Pass FUNCTION two args: an interval, and ARG. */
223 223
224void 224void
225traverse_intervals (INTERVAL tree, int position, void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg) 225traverse_intervals (INTERVAL tree, EMACS_INT position,
226 void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg)
226{ 227{
227 while (!NULL_INTERVAL_P (tree)) 228 while (!NULL_INTERVAL_P (tree))
228 { 229 {
@@ -316,7 +317,7 @@ rotate_right (INTERVAL interval)
316{ 317{
317 INTERVAL i; 318 INTERVAL i;
318 INTERVAL B = interval->left; 319 INTERVAL B = interval->left;
319 int old_total = interval->total_length; 320 EMACS_INT old_total = interval->total_length;
320 321
321 /* Deal with any Parent of A; make it point to B. */ 322 /* Deal with any Parent of A; make it point to B. */
322 if (! ROOT_INTERVAL_P (interval)) 323 if (! ROOT_INTERVAL_P (interval))
@@ -363,7 +364,7 @@ rotate_left (INTERVAL interval)
363{ 364{
364 INTERVAL i; 365 INTERVAL i;
365 INTERVAL B = interval->right; 366 INTERVAL B = interval->right;
366 int old_total = interval->total_length; 367 EMACS_INT old_total = interval->total_length;
367 368
368 /* Deal with any parent of A; make it point to B. */ 369 /* Deal with any parent of A; make it point to B. */
369 if (! ROOT_INTERVAL_P (interval)) 370 if (! ROOT_INTERVAL_P (interval))
@@ -402,7 +403,7 @@ rotate_left (INTERVAL interval)
402static INTERVAL 403static INTERVAL
403balance_an_interval (INTERVAL i) 404balance_an_interval (INTERVAL i)
404{ 405{
405 register int old_diff, new_diff; 406 register EMACS_INT old_diff, new_diff;
406 407
407 while (1) 408 while (1)
408 { 409 {
@@ -502,11 +503,11 @@ balance_intervals (INTERVAL tree)
502 it is still a root after this operation. */ 503 it is still a root after this operation. */
503 504
504INTERVAL 505INTERVAL
505split_interval_right (INTERVAL interval, int offset) 506split_interval_right (INTERVAL interval, EMACS_INT offset)
506{ 507{
507 INTERVAL new = make_interval (); 508 INTERVAL new = make_interval ();
508 int position = interval->position; 509 EMACS_INT position = interval->position;
509 int new_length = LENGTH (interval) - offset; 510 EMACS_INT new_length = LENGTH (interval) - offset;
510 511
511 new->position = position + offset; 512 new->position = position + offset;
512 SET_INTERVAL_PARENT (new, interval); 513 SET_INTERVAL_PARENT (new, interval);
@@ -547,10 +548,10 @@ split_interval_right (INTERVAL interval, int offset)
547 it is still a root after this operation. */ 548 it is still a root after this operation. */
548 549
549INTERVAL 550INTERVAL
550split_interval_left (INTERVAL interval, int offset) 551split_interval_left (INTERVAL interval, EMACS_INT offset)
551{ 552{
552 INTERVAL new = make_interval (); 553 INTERVAL new = make_interval ();
553 int new_length = offset; 554 EMACS_INT new_length = offset;
554 555
555 new->position = interval->position; 556 new->position = interval->position;
556 interval->position = interval->position + offset; 557 interval->position = interval->position + offset;
@@ -613,11 +614,11 @@ interval_start_pos (INTERVAL source)
613 will update this cache based on the result of find_interval. */ 614 will update this cache based on the result of find_interval. */
614 615
615INTERVAL 616INTERVAL
616find_interval (register INTERVAL tree, register int position) 617find_interval (register INTERVAL tree, register EMACS_INT position)
617{ 618{
618 /* The distance from the left edge of the subtree at TREE 619 /* The distance from the left edge of the subtree at TREE
619 to POSITION. */ 620 to POSITION. */
620 register int relative_position; 621 register EMACS_INT relative_position;
621 622
622 if (NULL_INTERVAL_P (tree)) 623 if (NULL_INTERVAL_P (tree))
623 return NULL_INTERVAL; 624 return NULL_INTERVAL;
@@ -670,7 +671,7 @@ INTERVAL
670next_interval (register INTERVAL interval) 671next_interval (register INTERVAL interval)
671{ 672{
672 register INTERVAL i = interval; 673 register INTERVAL i = interval;
673 register int next_position; 674 register EMACS_INT next_position;
674 675
675 if (NULL_INTERVAL_P (i)) 676 if (NULL_INTERVAL_P (i))
676 return NULL_INTERVAL; 677 return NULL_INTERVAL;
@@ -745,7 +746,7 @@ previous_interval (register INTERVAL interval)
745 To speed up the process, we assume that the ->position of 746 To speed up the process, we assume that the ->position of
746 I and all its parents is already uptodate. */ 747 I and all its parents is already uptodate. */
747INTERVAL 748INTERVAL
748update_interval (register INTERVAL i, int pos) 749update_interval (register INTERVAL i, EMACS_INT pos)
749{ 750{
750 if (NULL_INTERVAL_P (i)) 751 if (NULL_INTERVAL_P (i))
751 return NULL_INTERVAL; 752 return NULL_INTERVAL;
@@ -864,13 +865,14 @@ adjust_intervals_for_insertion (tree, position, length)
864 this text, and make it have the merged properties of both ends. */ 865 this text, and make it have the merged properties of both ends. */
865 866
866static INTERVAL 867static INTERVAL
867adjust_intervals_for_insertion (INTERVAL tree, int position, int length) 868adjust_intervals_for_insertion (INTERVAL tree,
869 EMACS_INT position, EMACS_INT length)
868{ 870{
869 register INTERVAL i; 871 register INTERVAL i;
870 register INTERVAL temp; 872 register INTERVAL temp;
871 int eobp = 0; 873 int eobp = 0;
872 Lisp_Object parent; 874 Lisp_Object parent;
873 int offset; 875 EMACS_INT offset;
874 876
875 if (TOTAL_LENGTH (tree) == 0) /* Paranoia */ 877 if (TOTAL_LENGTH (tree) == 0) /* Paranoia */
876 abort (); 878 abort ();
@@ -1228,7 +1230,7 @@ static INTERVAL
1228delete_node (register INTERVAL i) 1230delete_node (register INTERVAL i)
1229{ 1231{
1230 register INTERVAL migrate, this; 1232 register INTERVAL migrate, this;
1231 register int migrate_amt; 1233 register EMACS_INT migrate_amt;
1232 1234
1233 if (NULL_INTERVAL_P (i->left)) 1235 if (NULL_INTERVAL_P (i->left))
1234 return i->right; 1236 return i->right;
@@ -1261,7 +1263,7 @@ void
1261delete_interval (register INTERVAL i) 1263delete_interval (register INTERVAL i)
1262{ 1264{
1263 register INTERVAL parent; 1265 register INTERVAL parent;
1264 int amt = LENGTH (i); 1266 EMACS_INT amt = LENGTH (i);
1265 1267
1266 if (amt > 0) /* Only used on zero-length intervals now. */ 1268 if (amt > 0) /* Only used on zero-length intervals now. */
1267 abort (); 1269 abort ();
@@ -1311,10 +1313,11 @@ delete_interval (register INTERVAL i)
1311 Do this by recursing down TREE to the interval in question, and 1313 Do this by recursing down TREE to the interval in question, and
1312 deleting the appropriate amount of text. */ 1314 deleting the appropriate amount of text. */
1313 1315
1314static int 1316static EMACS_INT
1315interval_deletion_adjustment (register INTERVAL tree, register int from, register int amount) 1317interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
1318 register EMACS_INT amount)
1316{ 1319{
1317 register int relative_position = from; 1320 register EMACS_INT relative_position = from;
1318 1321
1319 if (NULL_INTERVAL_P (tree)) 1322 if (NULL_INTERVAL_P (tree))
1320 return 0; 1323 return 0;
@@ -1322,9 +1325,9 @@ interval_deletion_adjustment (register INTERVAL tree, register int from, registe
1322 /* Left branch */ 1325 /* Left branch */
1323 if (relative_position < LEFT_TOTAL_LENGTH (tree)) 1326 if (relative_position < LEFT_TOTAL_LENGTH (tree))
1324 { 1327 {
1325 int subtract = interval_deletion_adjustment (tree->left, 1328 EMACS_INT subtract = interval_deletion_adjustment (tree->left,
1326 relative_position, 1329 relative_position,
1327 amount); 1330 amount);
1328 tree->total_length -= subtract; 1331 tree->total_length -= subtract;
1329 CHECK_TOTAL_LENGTH (tree); 1332 CHECK_TOTAL_LENGTH (tree);
1330 return subtract; 1333 return subtract;
@@ -1333,7 +1336,7 @@ interval_deletion_adjustment (register INTERVAL tree, register int from, registe
1333 else if (relative_position >= (TOTAL_LENGTH (tree) 1336 else if (relative_position >= (TOTAL_LENGTH (tree)
1334 - RIGHT_TOTAL_LENGTH (tree))) 1337 - RIGHT_TOTAL_LENGTH (tree)))
1335 { 1338 {
1336 int subtract; 1339 EMACS_INT subtract;
1337 1340
1338 relative_position -= (tree->total_length 1341 relative_position -= (tree->total_length
1339 - RIGHT_TOTAL_LENGTH (tree)); 1342 - RIGHT_TOTAL_LENGTH (tree));
@@ -1348,9 +1351,9 @@ interval_deletion_adjustment (register INTERVAL tree, register int from, registe
1348 else 1351 else
1349 { 1352 {
1350 /* How much can we delete from this interval? */ 1353 /* How much can we delete from this interval? */
1351 int my_amount = ((tree->total_length 1354 EMACS_INT my_amount = ((tree->total_length
1352 - RIGHT_TOTAL_LENGTH (tree)) 1355 - RIGHT_TOTAL_LENGTH (tree))
1353 - relative_position); 1356 - relative_position);
1354 1357
1355 if (amount > my_amount) 1358 if (amount > my_amount)
1356 amount = my_amount; 1359 amount = my_amount;
@@ -1372,12 +1375,13 @@ interval_deletion_adjustment (register INTERVAL tree, register int from, registe
1372 buffer position, i.e. origin 1). */ 1375 buffer position, i.e. origin 1). */
1373 1376
1374static void 1377static void
1375adjust_intervals_for_deletion (struct buffer *buffer, int start, int length) 1378adjust_intervals_for_deletion (struct buffer *buffer,
1379 EMACS_INT start, EMACS_INT length)
1376{ 1380{
1377 register int left_to_delete = length; 1381 register EMACS_INT left_to_delete = length;
1378 register INTERVAL tree = BUF_INTERVALS (buffer); 1382 register INTERVAL tree = BUF_INTERVALS (buffer);
1379 Lisp_Object parent; 1383 Lisp_Object parent;
1380 int offset; 1384 EMACS_INT offset;
1381 1385
1382 GET_INTERVAL_OBJECT (parent, tree); 1386 GET_INTERVAL_OBJECT (parent, tree);
1383 offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0); 1387 offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0);
@@ -1423,7 +1427,7 @@ adjust_intervals_for_deletion (struct buffer *buffer, int start, int length)
1423 of LENGTH. */ 1427 of LENGTH. */
1424 1428
1425INLINE void 1429INLINE void
1426offset_intervals (struct buffer *buffer, int start, int length) 1430offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length)
1427{ 1431{
1428 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) 1432 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0)
1429 return; 1433 return;
@@ -1446,7 +1450,7 @@ offset_intervals (struct buffer *buffer, int start, int length)
1446INTERVAL 1450INTERVAL
1447merge_interval_right (register INTERVAL i) 1451merge_interval_right (register INTERVAL i)
1448{ 1452{
1449 register int absorb = LENGTH (i); 1453 register EMACS_INT absorb = LENGTH (i);
1450 register INTERVAL successor; 1454 register INTERVAL successor;
1451 1455
1452 /* Zero out this interval. */ 1456 /* Zero out this interval. */
@@ -1502,7 +1506,7 @@ merge_interval_right (register INTERVAL i)
1502INTERVAL 1506INTERVAL
1503merge_interval_left (register INTERVAL i) 1507merge_interval_left (register INTERVAL i)
1504{ 1508{
1505 register int absorb = LENGTH (i); 1509 register EMACS_INT absorb = LENGTH (i);
1506 register INTERVAL predecessor; 1510 register INTERVAL predecessor;
1507 1511
1508 /* Zero out this interval. */ 1512 /* Zero out this interval. */
@@ -1598,7 +1602,7 @@ reproduce_tree_obj (INTERVAL source, Lisp_Object parent)
1598static INTERVAL 1602static INTERVAL
1599make_new_interval (intervals, start, length) 1603make_new_interval (intervals, start, length)
1600 INTERVAL intervals; 1604 INTERVAL intervals;
1601 int start, length; 1605 EMACS_INT start, length;
1602{ 1606{
1603 INTERVAL slot; 1607 INTERVAL slot;
1604 1608
@@ -1670,11 +1674,13 @@ make_new_interval (intervals, start, length)
1670 text... */ 1674 text... */
1671 1675
1672void 1676void
1673graft_intervals_into_buffer (INTERVAL source, int position, int length, struct buffer *buffer, int inherit) 1677graft_intervals_into_buffer (INTERVAL source, EMACS_INT position,
1678 EMACS_INT length, struct buffer *buffer,
1679 int inherit)
1674{ 1680{
1675 register INTERVAL under, over, this, prev; 1681 register INTERVAL under, over, this, prev;
1676 register INTERVAL tree; 1682 register INTERVAL tree;
1677 int over_used; 1683 EMACS_INT over_used;
1678 1684
1679 tree = BUF_INTERVALS (buffer); 1685 tree = BUF_INTERVALS (buffer);
1680 1686
@@ -1920,8 +1926,9 @@ set_point (EMACS_INT charpos)
1920 Note that `stickiness' is determined by overlay marker insertion types, 1926 Note that `stickiness' is determined by overlay marker insertion types,
1921 if the invisible property comes from an overlay. */ 1927 if the invisible property comes from an overlay. */
1922 1928
1923static int 1929static EMACS_INT
1924adjust_for_invis_intang (int pos, int test_offs, int adj, int test_intang) 1930adjust_for_invis_intang (EMACS_INT pos, EMACS_INT test_offs, EMACS_INT adj,
1931 int test_intang)
1925{ 1932{
1926 Lisp_Object invis_propval, invis_overlay; 1933 Lisp_Object invis_propval, invis_overlay;
1927 Lisp_Object test_pos; 1934 Lisp_Object test_pos;
@@ -2183,7 +2190,7 @@ set_point_both (EMACS_INT charpos, EMACS_INT bytepos)
2183 segment that reaches all the way to point. */ 2190 segment that reaches all the way to point. */
2184 2191
2185void 2192void
2186move_if_not_intangible (int position) 2193move_if_not_intangible (EMACS_INT position)
2187{ 2194{
2188 Lisp_Object pos; 2195 Lisp_Object pos;
2189 Lisp_Object intangible_propval; 2196 Lisp_Object intangible_propval;
@@ -2246,7 +2253,8 @@ move_if_not_intangible (int position)
2246 nil means the current buffer. */ 2253 nil means the current buffer. */
2247 2254
2248int 2255int
2249get_property_and_range (int pos, Lisp_Object prop, Lisp_Object *val, EMACS_INT *start, EMACS_INT *end, Lisp_Object object) 2256get_property_and_range (EMACS_INT pos, Lisp_Object prop, Lisp_Object *val,
2257 EMACS_INT *start, EMACS_INT *end, Lisp_Object object)
2250{ 2258{
2251 INTERVAL i, prev, next; 2259 INTERVAL i, prev, next;
2252 2260
@@ -2289,10 +2297,11 @@ get_property_and_range (int pos, Lisp_Object prop, Lisp_Object *val, EMACS_INT *
2289 POSITION must be in the accessible part of BUFFER. */ 2297 POSITION must be in the accessible part of BUFFER. */
2290 2298
2291Lisp_Object 2299Lisp_Object
2292get_local_map (register int position, register struct buffer *buffer, Lisp_Object type) 2300get_local_map (register EMACS_INT position, register struct buffer *buffer,
2301 Lisp_Object type)
2293{ 2302{
2294 Lisp_Object prop, lispy_position, lispy_buffer; 2303 Lisp_Object prop, lispy_position, lispy_buffer;
2295 int old_begv, old_zv, old_begv_byte, old_zv_byte; 2304 EMACS_INT old_begv, old_zv, old_begv_byte, old_zv_byte;
2296 2305
2297 /* Perhaps we should just change `position' to the limit. */ 2306 /* Perhaps we should just change `position' to the limit. */
2298 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer)) 2307 if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer))
@@ -2342,10 +2351,10 @@ get_local_map (register int position, register struct buffer *buffer, Lisp_Objec
2342 The new interval tree has no parent and has a starting-position of 0. */ 2351 The new interval tree has no parent and has a starting-position of 0. */
2343 2352
2344INTERVAL 2353INTERVAL
2345copy_intervals (INTERVAL tree, int start, int length) 2354copy_intervals (INTERVAL tree, EMACS_INT start, EMACS_INT length)
2346{ 2355{
2347 register INTERVAL i, new, t; 2356 register INTERVAL i, new, t;
2348 register int got, prevlen; 2357 register EMACS_INT got, prevlen;
2349 2358
2350 if (NULL_INTERVAL_P (tree) || length <= 0) 2359 if (NULL_INTERVAL_P (tree) || length <= 0)
2351 return NULL_INTERVAL; 2360 return NULL_INTERVAL;
@@ -2383,7 +2392,8 @@ copy_intervals (INTERVAL tree, int start, int length)
2383/* Give STRING the properties of BUFFER from POSITION to LENGTH. */ 2392/* Give STRING the properties of BUFFER from POSITION to LENGTH. */
2384 2393
2385INLINE void 2394INLINE void
2386copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, int position, int length) 2395copy_intervals_to_string (Lisp_Object string, struct buffer *buffer,
2396 EMACS_INT position, EMACS_INT length)
2387{ 2397{
2388 INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer), 2398 INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer),
2389 position, length); 2399 position, length);
@@ -2401,8 +2411,8 @@ int
2401compare_string_intervals (Lisp_Object s1, Lisp_Object s2) 2411compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
2402{ 2412{
2403 INTERVAL i1, i2; 2413 INTERVAL i1, i2;
2404 int pos = 0; 2414 EMACS_INT pos = 0;
2405 int end = SCHARS (s1); 2415 EMACS_INT end = SCHARS (s1);
2406 2416
2407 i1 = find_interval (STRING_INTERVALS (s1), 0); 2417 i1 = find_interval (STRING_INTERVALS (s1), 0);
2408 i2 = find_interval (STRING_INTERVALS (s2), 0); 2418 i2 = find_interval (STRING_INTERVALS (s2), 0);
@@ -2410,9 +2420,9 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
2410 while (pos < end) 2420 while (pos < end)
2411 { 2421 {
2412 /* Determine how far we can go before we reach the end of I1 or I2. */ 2422 /* Determine how far we can go before we reach the end of I1 or I2. */
2413 int len1 = (i1 != 0 ? INTERVAL_LAST_POS (i1) : end) - pos; 2423 EMACS_INT len1 = (i1 != 0 ? INTERVAL_LAST_POS (i1) : end) - pos;
2414 int len2 = (i2 != 0 ? INTERVAL_LAST_POS (i2) : end) - pos; 2424 EMACS_INT len2 = (i2 != 0 ? INTERVAL_LAST_POS (i2) : end) - pos;
2415 int distance = min (len1, len2); 2425 EMACS_INT distance = min (len1, len2);
2416 2426
2417 /* If we ever find a mismatch between the strings, 2427 /* If we ever find a mismatch between the strings,
2418 they differ. */ 2428 they differ. */
@@ -2436,7 +2446,9 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
2436 START_BYTE ... END_BYTE in bytes. */ 2446 START_BYTE ... END_BYTE in bytes. */
2437 2447
2438static void 2448static void
2439set_intervals_multibyte_1 (INTERVAL i, int multi_flag, int start, int start_byte, int end, int end_byte) 2449set_intervals_multibyte_1 (INTERVAL i, int multi_flag,
2450 EMACS_INT start, EMACS_INT start_byte,
2451 EMACS_INT end, EMACS_INT end_byte)
2440{ 2452{
2441 /* Fix the length of this interval. */ 2453 /* Fix the length of this interval. */
2442 if (multi_flag) 2454 if (multi_flag)
@@ -2454,11 +2466,11 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag, int start, int start_byte
2454 /* Recursively fix the length of the subintervals. */ 2466 /* Recursively fix the length of the subintervals. */
2455 if (i->left) 2467 if (i->left)
2456 { 2468 {
2457 int left_end, left_end_byte; 2469 EMACS_INT left_end, left_end_byte;
2458 2470
2459 if (multi_flag) 2471 if (multi_flag)
2460 { 2472 {
2461 int temp; 2473 EMACS_INT temp;
2462 left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); 2474 left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i);
2463 left_end = BYTE_TO_CHAR (left_end_byte); 2475 left_end = BYTE_TO_CHAR (left_end_byte);
2464 2476
@@ -2487,11 +2499,11 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag, int start, int start_byte
2487 } 2499 }
2488 if (i->right) 2500 if (i->right)
2489 { 2501 {
2490 int right_start_byte, right_start; 2502 EMACS_INT right_start_byte, right_start;
2491 2503
2492 if (multi_flag) 2504 if (multi_flag)
2493 { 2505 {
2494 int temp; 2506 EMACS_INT temp;
2495 2507
2496 right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); 2508 right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i);
2497 right_start = BYTE_TO_CHAR (right_start_byte); 2509 right_start = BYTE_TO_CHAR (right_start_byte);
diff --git a/src/intervals.h b/src/intervals.h
index 612c1a99848..b39fbd6899d 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -250,36 +250,36 @@ extern INTERVAL make_interval (void);
250extern INTERVAL create_root_interval (Lisp_Object); 250extern INTERVAL create_root_interval (Lisp_Object);
251extern void copy_properties (INTERVAL, INTERVAL); 251extern void copy_properties (INTERVAL, INTERVAL);
252extern int intervals_equal (INTERVAL, INTERVAL); 252extern int intervals_equal (INTERVAL, INTERVAL);
253extern void traverse_intervals (INTERVAL, int, 253extern void traverse_intervals (INTERVAL, EMACS_INT,
254 void (*) (INTERVAL, Lisp_Object), 254 void (*) (INTERVAL, Lisp_Object),
255 Lisp_Object); 255 Lisp_Object);
256extern void traverse_intervals_noorder (INTERVAL, 256extern void traverse_intervals_noorder (INTERVAL,
257 void (*) (INTERVAL, Lisp_Object), 257 void (*) (INTERVAL, Lisp_Object),
258 Lisp_Object); 258 Lisp_Object);
259extern INTERVAL split_interval_right (INTERVAL, int); 259extern INTERVAL split_interval_right (INTERVAL, EMACS_INT);
260extern INTERVAL split_interval_left (INTERVAL, int); 260extern INTERVAL split_interval_left (INTERVAL, EMACS_INT);
261extern INTERVAL find_interval (INTERVAL, int); 261extern INTERVAL find_interval (INTERVAL, EMACS_INT);
262extern INTERVAL next_interval (INTERVAL); 262extern INTERVAL next_interval (INTERVAL);
263extern INTERVAL previous_interval (INTERVAL); 263extern INTERVAL previous_interval (INTERVAL);
264extern INTERVAL merge_interval_left (INTERVAL); 264extern INTERVAL merge_interval_left (INTERVAL);
265extern INTERVAL merge_interval_right (INTERVAL); 265extern INTERVAL merge_interval_right (INTERVAL);
266extern void delete_interval (INTERVAL); 266extern void delete_interval (INTERVAL);
267extern INLINE void offset_intervals (struct buffer *, int, int); 267extern INLINE void offset_intervals (struct buffer *, EMACS_INT, EMACS_INT);
268extern void graft_intervals_into_buffer (INTERVAL, int, int, 268extern void graft_intervals_into_buffer (INTERVAL, EMACS_INT, EMACS_INT,
269 struct buffer *, int); 269 struct buffer *, int);
270extern void verify_interval_modification (struct buffer *, int, int); 270extern void verify_interval_modification (struct buffer *, int, int);
271extern INTERVAL balance_intervals (INTERVAL); 271extern INTERVAL balance_intervals (INTERVAL);
272extern INLINE void copy_intervals_to_string (Lisp_Object, struct buffer *, 272extern INLINE void copy_intervals_to_string (Lisp_Object, struct buffer *,
273 int, int); 273 EMACS_INT, EMACS_INT);
274extern INTERVAL copy_intervals (INTERVAL, int, int); 274extern INTERVAL copy_intervals (INTERVAL, EMACS_INT, EMACS_INT);
275extern int compare_string_intervals (Lisp_Object, Lisp_Object); 275extern int compare_string_intervals (Lisp_Object, Lisp_Object);
276extern Lisp_Object textget (Lisp_Object, Lisp_Object); 276extern Lisp_Object textget (Lisp_Object, Lisp_Object);
277extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, int); 277extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, int);
278extern void move_if_not_intangible (int); 278extern void move_if_not_intangible (EMACS_INT);
279extern int get_property_and_range (int, Lisp_Object, Lisp_Object *, 279extern int get_property_and_range (EMACS_INT, Lisp_Object, Lisp_Object *,
280 EMACS_INT *, EMACS_INT *, Lisp_Object); 280 EMACS_INT *, EMACS_INT *, Lisp_Object);
281extern Lisp_Object get_local_map (int, struct buffer *, Lisp_Object); 281extern Lisp_Object get_local_map (EMACS_INT, struct buffer *, Lisp_Object);
282extern INTERVAL update_interval (INTERVAL, int); 282extern INTERVAL update_interval (INTERVAL, EMACS_INT);
283extern void set_intervals_multibyte (int); 283extern void set_intervals_multibyte (int);
284extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *, 284extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *,
285 Lisp_Object *, int); 285 Lisp_Object *, int);
diff --git a/src/keyboard.c b/src/keyboard.c
index 95fc275ffe8..b77689bde06 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -304,7 +304,7 @@ EMACS_INT extra_keyboard_modifiers;
304Lisp_Object meta_prefix_char; 304Lisp_Object meta_prefix_char;
305 305
306/* Last size recorded for a current buffer which is not a minibuffer. */ 306/* Last size recorded for a current buffer which is not a minibuffer. */
307static int last_non_minibuf_size; 307static EMACS_INT last_non_minibuf_size;
308 308
309/* Number of idle seconds before an auto-save and garbage collection. */ 309/* Number of idle seconds before an auto-save and garbage collection. */
310static Lisp_Object Vauto_save_timeout; 310static Lisp_Object Vauto_save_timeout;
@@ -337,7 +337,7 @@ Lisp_Object real_this_command;
337Lisp_Object Vthis_original_command; 337Lisp_Object Vthis_original_command;
338 338
339/* The value of point when the last command was started. */ 339/* The value of point when the last command was started. */
340int last_point_position; 340EMACS_INT last_point_position;
341 341
342/* The buffer that was current when the last command was started. */ 342/* The buffer that was current when the last command was started. */
343Lisp_Object last_point_position_buffer; 343Lisp_Object last_point_position_buffer;
@@ -621,7 +621,7 @@ static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object,
621 Lisp_Object, Lisp_Object, 621 Lisp_Object, Lisp_Object,
622 unsigned long); 622 unsigned long);
623#endif 623#endif
624static Lisp_Object modify_event_symbol (int, unsigned, Lisp_Object, 624static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object,
625 Lisp_Object, const char **, 625 Lisp_Object, const char **,
626 Lisp_Object *, unsigned); 626 Lisp_Object *, unsigned);
627static Lisp_Object make_lispy_switch_frame (Lisp_Object); 627static Lisp_Object make_lispy_switch_frame (Lisp_Object);
@@ -867,7 +867,7 @@ echo_length (void)
867 switches frames while entering a key sequence. */ 867 switches frames while entering a key sequence. */
868 868
869static void 869static void
870echo_truncate (int nchars) 870echo_truncate (EMACS_INT nchars)
871{ 871{
872 if (STRINGP (current_kboard->echo_string)) 872 if (STRINGP (current_kboard->echo_string))
873 current_kboard->echo_string 873 current_kboard->echo_string
@@ -1480,7 +1480,7 @@ some_mouse_moved (void)
1480static int read_key_sequence (Lisp_Object *, int, Lisp_Object, 1480static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
1481 int, int, int); 1481 int, int, int);
1482void safe_run_hooks (Lisp_Object); 1482void safe_run_hooks (Lisp_Object);
1483static void adjust_point_for_property (int, int); 1483static void adjust_point_for_property (EMACS_INT, int);
1484 1484
1485/* Cancel hourglass from protect_unwind. 1485/* Cancel hourglass from protect_unwind.
1486 ARG is not used. */ 1486 ARG is not used. */
@@ -1811,8 +1811,9 @@ command_loop_1 (void)
1811 && !NILP (Vtransient_mark_mode))) 1811 && !NILP (Vtransient_mark_mode)))
1812 && !EQ (Vthis_command, Qhandle_switch_frame)) 1812 && !EQ (Vthis_command, Qhandle_switch_frame))
1813 { 1813 {
1814 int beg = XINT (Fmarker_position (current_buffer->mark)); 1814 EMACS_INT beg =
1815 int end = XINT (make_number (PT)); 1815 XINT (Fmarker_position (current_buffer->mark));
1816 EMACS_INT end = PT;
1816 if (beg < end) 1817 if (beg < end)
1817 call2 (Qx_set_selection, QPRIMARY, 1818 call2 (Qx_set_selection, QPRIMARY,
1818 make_buffer_string (beg, end, 0)); 1819 make_buffer_string (beg, end, 0));
@@ -1869,7 +1870,7 @@ command_loop_1 (void)
1869 LAST_PT is the last position of point. */ 1870 LAST_PT is the last position of point. */
1870 1871
1871static void 1872static void
1872adjust_point_for_property (int last_pt, int modified) 1873adjust_point_for_property (EMACS_INT last_pt, int modified)
1873{ 1874{
1874 EMACS_INT beg, end; 1875 EMACS_INT beg, end;
1875 Lisp_Object val, overlay, tmp; 1876 Lisp_Object val, overlay, tmp;
@@ -1878,7 +1879,7 @@ adjust_point_for_property (int last_pt, int modified)
1878 user can keep inserting another character at point or keep 1879 user can keep inserting another character at point or keep
1879 deleting characters around point. */ 1880 deleting characters around point. */
1880 int check_composition = ! modified, check_display = 1, check_invisible = 1; 1881 int check_composition = ! modified, check_display = 1, check_invisible = 1;
1881 int orig_pt = PT; 1882 EMACS_INT orig_pt = PT;
1882 1883
1883 /* FIXME: cycling is probably not necessary because these properties 1884 /* FIXME: cycling is probably not necessary because these properties
1884 can't be usefully combined anyway. */ 1885 can't be usefully combined anyway. */
@@ -2781,7 +2782,8 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
2781 2782
2782 if (INTERACTIVE && NILP (c)) 2783 if (INTERACTIVE && NILP (c))
2783 { 2784 {
2784 int delay_level, buffer_size; 2785 int delay_level;
2786 EMACS_INT buffer_size;
2785 2787
2786 /* Slow down auto saves logarithmically in size of current buffer, 2788 /* Slow down auto saves logarithmically in size of current buffer,
2787 and garbage collect while we're at it. */ 2789 and garbage collect while we're at it. */
@@ -3520,12 +3522,6 @@ restore_getcjmp (jmp_buf temp)
3520static int 3522static int
3521readable_events (int flags) 3523readable_events (int flags)
3522{ 3524{
3523#ifdef HAVE_DBUS
3524 /* Check whether a D-Bus message has arrived. */
3525 if (xd_pending_messages () > 0)
3526 return 1;
3527#endif /* HAVE_DBUS */
3528
3529 if (flags & READABLE_EVENTS_DO_TIMERS_NOW) 3525 if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
3530 timer_check (1); 3526 timer_check (1);
3531 3527
@@ -3795,22 +3791,20 @@ kbd_buffer_unget_event (register struct input_event *event)
3795} 3791}
3796 3792
3797 3793
3798/* Generate HELP_EVENT input_events in BUFP which has room for 3794/* Generate a HELP_EVENT input_event and store it in the keyboard
3799 SIZE events. If there's not enough room in BUFP, ignore this 3795 buffer.
3800 event.
3801 3796
3802 HELP is the help form. 3797 HELP is the help form.
3803 3798
3804 FRAME is the frame on which the help is generated. OBJECT is the 3799 FRAME and WINDOW are the frame and window where the help is
3805 Lisp object where the help was found (a buffer, a string, an 3800 generated. OBJECT is the Lisp object where the help was found (a
3806 overlay, or nil if neither from a string nor from a buffer. POS is 3801 buffer, a string, an overlay, or nil if neither from a string nor
3807 the position within OBJECT where the help was found. 3802 from a buffer). POS is the position within OBJECT where the help
3808 3803 was found. */
3809 Value is the number of input_events generated. */
3810 3804
3811void 3805void
3812gen_help_event (Lisp_Object help, Lisp_Object frame, Lisp_Object window, 3806gen_help_event (Lisp_Object help, Lisp_Object frame, Lisp_Object window,
3813 Lisp_Object object, int pos) 3807 Lisp_Object object, EMACS_INT pos)
3814{ 3808{
3815 struct input_event event; 3809 struct input_event event;
3816 3810
@@ -5280,7 +5274,8 @@ make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y,
5280 /* It's a click in window window at frame coordinates (x,y) */ 5274 /* It's a click in window window at frame coordinates (x,y) */
5281 struct window *w = XWINDOW (window); 5275 struct window *w = XWINDOW (window);
5282 Lisp_Object string_info = Qnil; 5276 Lisp_Object string_info = Qnil;
5283 int textpos = -1, rx = -1, ry = -1; 5277 EMACS_INT textpos = -1;
5278 int rx = -1, ry = -1;
5284 int dx = -1, dy = -1; 5279 int dx = -1, dy = -1;
5285 int width = -1, height = -1; 5280 int width = -1, height = -1;
5286 Lisp_Object object = Qnil; 5281 Lisp_Object object = Qnil;
@@ -5299,7 +5294,7 @@ make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y,
5299 /* Mode line or header line. Look for a string under 5294 /* Mode line or header line. Look for a string under
5300 the mouse that may have a `local-map' property. */ 5295 the mouse that may have a `local-map' property. */
5301 Lisp_Object string; 5296 Lisp_Object string;
5302 int charpos; 5297 EMACS_INT charpos;
5303 5298
5304 posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; 5299 posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line;
5305 rx = wx, ry = wy; 5300 rx = wx, ry = wy;
@@ -5323,7 +5318,7 @@ make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y,
5323 else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) 5318 else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
5324 { 5319 {
5325 Lisp_Object string; 5320 Lisp_Object string;
5326 int charpos; 5321 EMACS_INT charpos;
5327 5322
5328 posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; 5323 posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin;
5329 rx = wx, ry = wy; 5324 rx = wx, ry = wy;
@@ -5458,7 +5453,7 @@ make_lispy_event (struct input_event *event)
5458 case MULTIBYTE_CHAR_KEYSTROKE_EVENT: 5453 case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
5459 { 5454 {
5460 Lisp_Object lispy_c; 5455 Lisp_Object lispy_c;
5461 int c = event->code; 5456 EMACS_INT c = event->code;
5462 if (event->kind == ASCII_KEYSTROKE_EVENT) 5457 if (event->kind == ASCII_KEYSTROKE_EVENT)
5463 { 5458 {
5464 c &= 0377; 5459 c &= 0377;
@@ -6582,7 +6577,7 @@ reorder_modifiers (Lisp_Object symbol)
6582 in the symbol's name. */ 6577 in the symbol's name. */
6583 6578
6584static Lisp_Object 6579static Lisp_Object
6585modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_kind, 6580modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object symbol_kind,
6586 Lisp_Object name_alist_or_stem, const char **name_table, 6581 Lisp_Object name_alist_or_stem, const char **name_table,
6587 Lisp_Object *symbol_table, unsigned int table_size) 6582 Lisp_Object *symbol_table, unsigned int table_size)
6588{ 6583{
@@ -6646,7 +6641,7 @@ modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_
6646 if (NILP (value)) 6641 if (NILP (value))
6647 { 6642 {
6648 char buf[20]; 6643 char buf[20];
6649 sprintf (buf, "key-%d", symbol_num); 6644 sprintf (buf, "key-%ld", (long)symbol_num);
6650 value = intern (buf); 6645 value = intern (buf);
6651 } 6646 }
6652 6647
@@ -6876,11 +6871,6 @@ get_input_pending (int *addr, int flags)
6876void 6871void
6877gobble_input (int expected) 6872gobble_input (int expected)
6878{ 6873{
6879#ifdef HAVE_DBUS
6880 /* Read D-Bus messages. */
6881 xd_read_queued_messages ();
6882#endif /* HAVE_DBUS */
6883
6884#ifdef SIGIO 6874#ifdef SIGIO
6885 if (interrupt_input) 6875 if (interrupt_input)
6886 { 6876 {
@@ -8305,7 +8295,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8305 { 8295 {
8306 const char *bad_label = "!!?GARBLED ITEM?!!"; 8296 const char *bad_label = "!!?GARBLED ITEM?!!";
8307 /* `:label LABEL-STRING'. */ 8297 /* `:label LABEL-STRING'. */
8308 PROP (TOOL_BAR_ITEM_HELP) = STRINGP (value) 8298 PROP (TOOL_BAR_ITEM_LABEL) = STRINGP (value)
8309 ? value 8299 ? value
8310 : make_string (bad_label, strlen (bad_label)); 8300 : make_string (bad_label, strlen (bad_label));
8311 have_label = 1; 8301 have_label = 1;
@@ -10352,7 +10342,7 @@ give to the command you invoke, if it asks for an argument. */)
10352 (Lisp_Object prefixarg) 10342 (Lisp_Object prefixarg)
10353{ 10343{
10354 Lisp_Object function; 10344 Lisp_Object function;
10355 int saved_last_point_position; 10345 EMACS_INT saved_last_point_position;
10356 Lisp_Object saved_keys, saved_last_point_position_buffer; 10346 Lisp_Object saved_keys, saved_last_point_position_buffer;
10357 Lisp_Object bindings, value; 10347 Lisp_Object bindings, value;
10358 struct gcpro gcpro1, gcpro2, gcpro3; 10348 struct gcpro gcpro1, gcpro2, gcpro3;
@@ -10820,7 +10810,7 @@ stuff_buffered_input (Lisp_Object stuffstring)
10820 10810
10821 if (STRINGP (stuffstring)) 10811 if (STRINGP (stuffstring))
10822 { 10812 {
10823 register int count; 10813 register EMACS_INT count;
10824 10814
10825 p = SDATA (stuffstring); 10815 p = SDATA (stuffstring);
10826 count = SBYTES (stuffstring); 10816 count = SBYTES (stuffstring);
diff --git a/src/keyboard.h b/src/keyboard.h
index a3bb46f4454..9fd3b48eba9 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -524,7 +524,7 @@ extern void poll_for_input_1 (void);
524extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object, 524extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object,
525 Lisp_Object, int); 525 Lisp_Object, int);
526extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object, 526extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object,
527 Lisp_Object, int); 527 Lisp_Object, EMACS_INT);
528extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object); 528extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object);
529extern Lisp_Object menu_item_eval_property (Lisp_Object); 529extern Lisp_Object menu_item_eval_property (Lisp_Object);
530extern int kbd_buffer_events_waiting (int); 530extern int kbd_buffer_events_waiting (int);
diff --git a/src/lisp.h b/src/lisp.h
index d44c05c661f..d942e792957 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -742,7 +742,7 @@ struct Lisp_Cons
742#ifdef GC_CHECK_STRING_BYTES 742#ifdef GC_CHECK_STRING_BYTES
743 743
744struct Lisp_String; 744struct Lisp_String;
745extern int string_bytes (struct Lisp_String *); 745extern EMACS_INT string_bytes (struct Lisp_String *);
746#define STRING_BYTES(S) string_bytes ((S)) 746#define STRING_BYTES(S) string_bytes ((S))
747 747
748#else /* not GC_CHECK_STRING_BYTES */ 748#else /* not GC_CHECK_STRING_BYTES */
@@ -1903,11 +1903,11 @@ struct specbinding
1903 1903
1904extern struct specbinding *specpdl; 1904extern struct specbinding *specpdl;
1905extern struct specbinding *specpdl_ptr; 1905extern struct specbinding *specpdl_ptr;
1906extern int specpdl_size; 1906extern EMACS_INT specpdl_size;
1907 1907
1908extern EMACS_INT max_specpdl_size; 1908extern EMACS_INT max_specpdl_size;
1909 1909
1910#define SPECPDL_INDEX() (specpdl_ptr - specpdl) 1910#define SPECPDL_INDEX() ((int) (specpdl_ptr - specpdl))
1911 1911
1912/* Everything needed to describe an active condition case. */ 1912/* Everything needed to describe an active condition case. */
1913struct handler 1913struct handler
@@ -2521,7 +2521,8 @@ EXFUN (Fstring_as_unibyte, 1);
2521EXFUN (Fstring_to_multibyte, 1); 2521EXFUN (Fstring_to_multibyte, 1);
2522EXFUN (Fstring_to_unibyte, 1); 2522EXFUN (Fstring_to_unibyte, 1);
2523EXFUN (Fsubstring, 3); 2523EXFUN (Fsubstring, 3);
2524extern Lisp_Object substring_both (Lisp_Object, int, int, int, int); 2524extern Lisp_Object substring_both (Lisp_Object, EMACS_INT, EMACS_INT,
2525 EMACS_INT, EMACS_INT);
2525EXFUN (Fnth, 2); 2526EXFUN (Fnth, 2);
2526EXFUN (Fnthcdr, 2); 2527EXFUN (Fnthcdr, 2);
2527EXFUN (Fmemq, 2); 2528EXFUN (Fmemq, 2);
@@ -2682,24 +2683,24 @@ extern Lisp_Object restore_message_unwind (Lisp_Object);
2682extern void pop_message (void); 2683extern void pop_message (void);
2683extern void restore_message (void); 2684extern void restore_message (void);
2684extern Lisp_Object current_message (void); 2685extern Lisp_Object current_message (void);
2685extern void set_message (const char *s, Lisp_Object, int, int); 2686extern void set_message (const char *s, Lisp_Object, EMACS_INT, int);
2686extern void clear_message (int, int); 2687extern void clear_message (int, int);
2687extern void message (const char *, ...); 2688extern void message (const char *, ...);
2688extern void message_nolog (const char *, ...); 2689extern void message_nolog (const char *, ...);
2689extern void message1 (const char *); 2690extern void message1 (const char *);
2690extern void message1_nolog (const char *); 2691extern void message1_nolog (const char *);
2691extern void message2 (const char *, int, int); 2692extern void message2 (const char *, EMACS_INT, int);
2692extern void message2_nolog (const char *, int, int); 2693extern void message2_nolog (const char *, EMACS_INT, int);
2693extern void message3 (Lisp_Object, int, int); 2694extern void message3 (Lisp_Object, EMACS_INT, int);
2694extern void message3_nolog (Lisp_Object, int, int); 2695extern void message3_nolog (Lisp_Object, EMACS_INT, int);
2695extern void message_dolog (const char *, int, int, int); 2696extern void message_dolog (const char *, EMACS_INT, int, int);
2696extern void message_with_string (const char *, Lisp_Object, int); 2697extern void message_with_string (const char *, Lisp_Object, int);
2697extern void message_log_maybe_newline (void); 2698extern void message_log_maybe_newline (void);
2698extern void update_echo_area (void); 2699extern void update_echo_area (void);
2699extern void truncate_echo_area (int); 2700extern void truncate_echo_area (EMACS_INT);
2700extern void redisplay (void); 2701extern void redisplay (void);
2701extern int check_point_in_composition 2702extern int check_point_in_composition
2702 (struct buffer *, int, struct buffer *, int); 2703 (struct buffer *, EMACS_INT, struct buffer *, EMACS_INT);
2703extern void redisplay_preserve_echo_area (int); 2704extern void redisplay_preserve_echo_area (int);
2704extern void prepare_menu_bars (void); 2705extern void prepare_menu_bars (void);
2705 2706
@@ -2707,7 +2708,7 @@ void set_frame_cursor_types (struct frame *, Lisp_Object);
2707extern void syms_of_xdisp (void); 2708extern void syms_of_xdisp (void);
2708extern void init_xdisp (void); 2709extern void init_xdisp (void);
2709extern Lisp_Object safe_eval (Lisp_Object); 2710extern Lisp_Object safe_eval (Lisp_Object);
2710extern int pos_visible_p (struct window *, int, int *, 2711extern int pos_visible_p (struct window *, EMACS_INT, int *,
2711 int *, int *, int *, int *, int *); 2712 int *, int *, int *, int *, int *);
2712 2713
2713/* Defined in xsettings.c */ 2714/* Defined in xsettings.c */
@@ -2718,7 +2719,7 @@ extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (const char *));
2718 2719
2719/* Defined in alloc.c */ 2720/* Defined in alloc.c */
2720extern void check_pure_size (void); 2721extern void check_pure_size (void);
2721extern void allocate_string_data (struct Lisp_String *, int, int); 2722extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
2722extern void reset_malloc_hooks (void); 2723extern void reset_malloc_hooks (void);
2723extern void uninterrupt_malloc (void); 2724extern void uninterrupt_malloc (void);
2724extern void malloc_warning (const char *); 2725extern void malloc_warning (const char *);
@@ -2745,16 +2746,17 @@ EXFUN (Fmake_symbol, 1);
2745EXFUN (Fmake_marker, 0); 2746EXFUN (Fmake_marker, 0);
2746EXFUN (Fmake_string, 2); 2747EXFUN (Fmake_string, 2);
2747extern Lisp_Object build_string (const char *); 2748extern Lisp_Object build_string (const char *);
2748extern Lisp_Object make_string (const char *, int); 2749extern Lisp_Object make_string (const char *, EMACS_INT);
2749extern Lisp_Object make_unibyte_string (const char *, int); 2750extern Lisp_Object make_unibyte_string (const char *, EMACS_INT);
2750extern Lisp_Object make_multibyte_string (const char *, int, int); 2751extern Lisp_Object make_multibyte_string (const char *, EMACS_INT, EMACS_INT);
2751extern Lisp_Object make_event_array (int, Lisp_Object *); 2752extern Lisp_Object make_event_array (int, Lisp_Object *);
2752extern Lisp_Object make_uninit_string (int); 2753extern Lisp_Object make_uninit_string (EMACS_INT);
2753extern Lisp_Object make_uninit_multibyte_string (int, int); 2754extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT);
2754extern Lisp_Object make_string_from_bytes (const char *, int, int); 2755extern Lisp_Object make_string_from_bytes (const char *, EMACS_INT, EMACS_INT);
2755extern Lisp_Object make_specified_string (const char *, int, int, int); 2756extern Lisp_Object make_specified_string (const char *,
2757 EMACS_INT, EMACS_INT, int);
2756EXFUN (Fpurecopy, 1); 2758EXFUN (Fpurecopy, 1);
2757extern Lisp_Object make_pure_string (const char *, int, int, int); 2759extern Lisp_Object make_pure_string (const char *, EMACS_INT, EMACS_INT, int);
2758extern Lisp_Object make_pure_c_string (const char *data); 2760extern Lisp_Object make_pure_c_string (const char *data);
2759extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); 2761extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
2760extern Lisp_Object make_pure_vector (EMACS_INT); 2762extern Lisp_Object make_pure_vector (EMACS_INT);
@@ -2843,7 +2845,7 @@ extern void float_to_string (unsigned char *, double);
2843extern void syms_of_print (void); 2845extern void syms_of_print (void);
2844 2846
2845/* Defined in doprnt.c */ 2847/* Defined in doprnt.c */
2846extern int doprnt (char *, int, const char *, const char *, va_list); 2848extern EMACS_INT doprnt (char *, int, const char *, const char *, va_list);
2847 2849
2848/* Defined in lread.c */ 2850/* Defined in lread.c */
2849extern Lisp_Object Vafter_load_alist; 2851extern Lisp_Object Vafter_load_alist;
@@ -2866,7 +2868,7 @@ extern Lisp_Object check_obarray (Lisp_Object);
2866extern Lisp_Object intern (const char *); 2868extern Lisp_Object intern (const char *);
2867extern Lisp_Object intern_c_string (const char *); 2869extern Lisp_Object intern_c_string (const char *);
2868extern Lisp_Object make_symbol (const char *); 2870extern Lisp_Object make_symbol (const char *);
2869extern Lisp_Object oblookup (Lisp_Object, const char *, int, int); 2871extern Lisp_Object oblookup (Lisp_Object, const char *, EMACS_INT, EMACS_INT);
2870#define LOADHIST_ATTACH(x) \ 2872#define LOADHIST_ATTACH(x) \
2871 do { \ 2873 do { \
2872 if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \ 2874 if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \
@@ -3018,9 +3020,10 @@ EXFUN (Fwiden, 0);
3018EXFUN (Fuser_login_name, 1); 3020EXFUN (Fuser_login_name, 1);
3019EXFUN (Fsystem_name, 0); 3021EXFUN (Fsystem_name, 0);
3020EXFUN (Fcurrent_time, 0); 3022EXFUN (Fcurrent_time, 0);
3021extern int clip_to_bounds (int, int, int); 3023extern EMACS_INT clip_to_bounds (EMACS_INT, EMACS_INT, EMACS_INT);
3022extern Lisp_Object make_buffer_string (int, int, int); 3024extern Lisp_Object make_buffer_string (EMACS_INT, EMACS_INT, int);
3023extern Lisp_Object make_buffer_string_both (int, int, int, int, int); 3025extern Lisp_Object make_buffer_string_both (EMACS_INT, EMACS_INT, EMACS_INT,
3026 EMACS_INT, int);
3024extern void init_editfns (void); 3027extern void init_editfns (void);
3025extern void syms_of_editfns (void); 3028extern void syms_of_editfns (void);
3026EXFUN (Fconstrain_to_field, 5); 3029EXFUN (Fconstrain_to_field, 5);
@@ -3040,10 +3043,10 @@ EXFUN (Foverlay_end, 1);
3040EXFUN (Foverlay_buffer, 1); 3043EXFUN (Foverlay_buffer, 1);
3041extern void adjust_overlays_for_insert (EMACS_INT, EMACS_INT); 3044extern void adjust_overlays_for_insert (EMACS_INT, EMACS_INT);
3042extern void adjust_overlays_for_delete (EMACS_INT, EMACS_INT); 3045extern void adjust_overlays_for_delete (EMACS_INT, EMACS_INT);
3043extern void fix_start_end_in_overlays (int, int); 3046extern void fix_start_end_in_overlays (EMACS_INT, EMACS_INT);
3044extern void report_overlay_modification (Lisp_Object, Lisp_Object, int, 3047extern void report_overlay_modification (Lisp_Object, Lisp_Object, int,
3045 Lisp_Object, Lisp_Object, Lisp_Object); 3048 Lisp_Object, Lisp_Object, Lisp_Object);
3046extern int overlay_touches_p (int); 3049extern int overlay_touches_p (EMACS_INT);
3047extern Lisp_Object Vbuffer_alist, Vinhibit_read_only; 3050extern Lisp_Object Vbuffer_alist, Vinhibit_read_only;
3048EXFUN (Fbuffer_list, 1); 3051EXFUN (Fbuffer_list, 1);
3049EXFUN (Fget_buffer, 1); 3052EXFUN (Fget_buffer, 1);
@@ -3080,17 +3083,17 @@ EXFUN (Fmarker_position, 1);
3080EXFUN (Fmarker_buffer, 1); 3083EXFUN (Fmarker_buffer, 1);
3081EXFUN (Fcopy_marker, 2); 3084EXFUN (Fcopy_marker, 2);
3082EXFUN (Fset_marker, 3); 3085EXFUN (Fset_marker, 3);
3083extern int marker_position (Lisp_Object); 3086extern EMACS_INT marker_position (Lisp_Object);
3084extern int marker_byte_position (Lisp_Object); 3087extern EMACS_INT marker_byte_position (Lisp_Object);
3085extern void clear_charpos_cache (struct buffer *); 3088extern void clear_charpos_cache (struct buffer *);
3086extern int charpos_to_bytepos (int); 3089extern EMACS_INT charpos_to_bytepos (EMACS_INT);
3087extern int buf_charpos_to_bytepos (struct buffer *, int); 3090extern EMACS_INT buf_charpos_to_bytepos (struct buffer *, EMACS_INT);
3088extern int buf_bytepos_to_charpos (struct buffer *, int); 3091extern EMACS_INT buf_bytepos_to_charpos (struct buffer *, EMACS_INT);
3089extern void unchain_marker (struct Lisp_Marker *marker); 3092extern void unchain_marker (struct Lisp_Marker *marker);
3090extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); 3093extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object);
3091extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, int, int); 3094extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT);
3092extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, 3095extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
3093 int, int); 3096 EMACS_INT, EMACS_INT);
3094extern void syms_of_marker (void); 3097extern void syms_of_marker (void);
3095 3098
3096/* Defined in fileio.c */ 3099/* Defined in fileio.c */
@@ -3148,12 +3151,13 @@ extern int fast_c_string_match_ignore_case (Lisp_Object, const char *);
3148extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object); 3151extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
3149extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT, 3152extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT,
3150 EMACS_INT, EMACS_INT, Lisp_Object); 3153 EMACS_INT, EMACS_INT, Lisp_Object);
3151extern int scan_buffer (int, EMACS_INT, EMACS_INT, int, int *, int); 3154extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT,
3152extern int scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, 3155 int *, int);
3153 int, int); 3156extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
3154extern int find_next_newline (EMACS_INT, int); 3157 EMACS_INT, int);
3155extern int find_next_newline_no_quit (EMACS_INT, int); 3158extern EMACS_INT find_next_newline (EMACS_INT, int);
3156extern int find_before_next_newline (EMACS_INT, EMACS_INT, int); 3159extern EMACS_INT find_next_newline_no_quit (EMACS_INT, EMACS_INT);
3160extern EMACS_INT find_before_next_newline (EMACS_INT, EMACS_INT, EMACS_INT);
3157extern void syms_of_search (void); 3161extern void syms_of_search (void);
3158extern void clear_regexp_cache (void); 3162extern void clear_regexp_cache (void);
3159 3163
@@ -3265,7 +3269,7 @@ EXFUN (Fcurrent_column, 0);
3265EXFUN (Fmove_to_column, 2); 3269EXFUN (Fmove_to_column, 2);
3266extern double current_column (void); 3270extern double current_column (void);
3267extern void invalidate_current_column (void); 3271extern void invalidate_current_column (void);
3268extern int indented_beyond_p (int, int, double); 3272extern int indented_beyond_p (EMACS_INT, EMACS_INT, double);
3269extern void syms_of_indent (void); 3273extern void syms_of_indent (void);
3270 3274
3271/* Defined in frame.c */ 3275/* Defined in frame.c */
@@ -3422,12 +3426,13 @@ extern Lisp_Object Qapply;
3422extern Lisp_Object Qinhibit_read_only; 3426extern Lisp_Object Qinhibit_read_only;
3423EXFUN (Fundo_boundary, 0); 3427EXFUN (Fundo_boundary, 0);
3424extern void truncate_undo_list (struct buffer *); 3428extern void truncate_undo_list (struct buffer *);
3425extern void record_marker_adjustment (Lisp_Object, int); 3429extern void record_marker_adjustment (Lisp_Object, EMACS_INT);
3426extern void record_insert (int, int); 3430extern void record_insert (EMACS_INT, EMACS_INT);
3427extern void record_delete (int, Lisp_Object); 3431extern void record_delete (EMACS_INT, Lisp_Object);
3428extern void record_first_change (void); 3432extern void record_first_change (void);
3429extern void record_change (int, int); 3433extern void record_change (EMACS_INT, EMACS_INT);
3430extern void record_property_change (int, int, Lisp_Object, Lisp_Object, 3434extern void record_property_change (EMACS_INT, EMACS_INT,
3435 Lisp_Object, Lisp_Object,
3431 Lisp_Object); 3436 Lisp_Object);
3432extern void syms_of_undo (void); 3437extern void syms_of_undo (void);
3433extern Lisp_Object Vundo_outer_limit; 3438extern Lisp_Object Vundo_outer_limit;
@@ -3618,8 +3623,6 @@ extern int have_menus_p (void);
3618 3623
3619#ifdef HAVE_DBUS 3624#ifdef HAVE_DBUS
3620/* Defined in dbusbind.c */ 3625/* Defined in dbusbind.c */
3621int xd_pending_messages (void);
3622void xd_read_queued_messages (void);
3623void syms_of_dbusbind (void); 3626void syms_of_dbusbind (void);
3624#endif 3627#endif
3625 3628
@@ -3752,7 +3755,7 @@ extern void init_system_name (void);
3752extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3755extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3753 3756
3754#define USE_SAFE_ALLOCA \ 3757#define USE_SAFE_ALLOCA \
3755 int sa_count = SPECPDL_INDEX (), sa_must_free = 0 3758 int sa_count = (int) SPECPDL_INDEX (), sa_must_free = 0
3756 3759
3757/* SAFE_ALLOCA allocates a simple buffer. */ 3760/* SAFE_ALLOCA allocates a simple buffer. */
3758 3761
diff --git a/src/lread.c b/src/lread.c
index 1a6d7e832f6..64633a6e442 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -169,13 +169,13 @@ static FILE *instream;
169static int read_pure; 169static int read_pure;
170 170
171/* For use within read-from-string (this reader is non-reentrant!!) */ 171/* For use within read-from-string (this reader is non-reentrant!!) */
172static int read_from_string_index; 172static EMACS_INT read_from_string_index;
173static int read_from_string_index_byte; 173static EMACS_INT read_from_string_index_byte;
174static int read_from_string_limit; 174static EMACS_INT read_from_string_limit;
175 175
176/* Number of characters read in the current call to Fread or 176/* Number of characters read in the current call to Fread or
177 Fread_from_string. */ 177 Fread_from_string. */
178static int readchar_count; 178static EMACS_INT readchar_count;
179 179
180/* This contains the last string skipped with #@. */ 180/* This contains the last string skipped with #@. */
181static char *saved_doc_string; 181static char *saved_doc_string;
@@ -282,7 +282,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
282 { 282 {
283 register struct buffer *inbuffer = XBUFFER (readcharfun); 283 register struct buffer *inbuffer = XBUFFER (readcharfun);
284 284
285 int pt_byte = BUF_PT_BYTE (inbuffer); 285 EMACS_INT pt_byte = BUF_PT_BYTE (inbuffer);
286 286
287 if (pt_byte >= BUF_ZV_BYTE (inbuffer)) 287 if (pt_byte >= BUF_ZV_BYTE (inbuffer))
288 return -1; 288 return -1;
@@ -311,7 +311,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
311 { 311 {
312 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; 312 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
313 313
314 int bytepos = marker_byte_position (readcharfun); 314 EMACS_INT bytepos = marker_byte_position (readcharfun);
315 315
316 if (bytepos >= BUF_ZV_BYTE (inbuffer)) 316 if (bytepos >= BUF_ZV_BYTE (inbuffer))
317 return -1; 317 return -1;
@@ -445,7 +445,7 @@ unreadchar (Lisp_Object readcharfun, int c)
445 else if (BUFFERP (readcharfun)) 445 else if (BUFFERP (readcharfun))
446 { 446 {
447 struct buffer *b = XBUFFER (readcharfun); 447 struct buffer *b = XBUFFER (readcharfun);
448 int bytepos = BUF_PT_BYTE (b); 448 EMACS_INT bytepos = BUF_PT_BYTE (b);
449 449
450 BUF_PT (b)--; 450 BUF_PT (b)--;
451 if (! NILP (b->enable_multibyte_characters)) 451 if (! NILP (b->enable_multibyte_characters))
@@ -458,7 +458,7 @@ unreadchar (Lisp_Object readcharfun, int c)
458 else if (MARKERP (readcharfun)) 458 else if (MARKERP (readcharfun))
459 { 459 {
460 struct buffer *b = XMARKER (readcharfun)->buffer; 460 struct buffer *b = XMARKER (readcharfun)->buffer;
461 int bytepos = XMARKER (readcharfun)->bytepos; 461 EMACS_INT bytepos = XMARKER (readcharfun)->bytepos;
462 462
463 XMARKER (readcharfun)->charpos--; 463 XMARKER (readcharfun)->charpos--;
464 if (! NILP (b->enable_multibyte_characters)) 464 if (! NILP (b->enable_multibyte_characters))
@@ -2035,7 +2035,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
2035 if (STRINGP (stream) 2035 if (STRINGP (stream)
2036 || ((CONSP (stream) && STRINGP (XCAR (stream))))) 2036 || ((CONSP (stream) && STRINGP (XCAR (stream)))))
2037 { 2037 {
2038 int startval, endval; 2038 EMACS_INT startval, endval;
2039 Lisp_Object string; 2039 Lisp_Object string;
2040 2040
2041 if (STRINGP (stream)) 2041 if (STRINGP (stream))
@@ -3896,7 +3896,7 @@ OBARRAY defaults to the value of the variable `obarray'. */)
3896 Also store the bucket number in oblookup_last_bucket_number. */ 3896 Also store the bucket number in oblookup_last_bucket_number. */
3897 3897
3898Lisp_Object 3898Lisp_Object
3899oblookup (Lisp_Object obarray, register const char *ptr, int size, int size_byte) 3899oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte)
3900{ 3900{
3901 int hash; 3901 int hash;
3902 int obsize; 3902 int obsize;
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 8d99d6cedfe..752a3c211b3 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1344,7 +1344,6 @@ $(BLD)/sysdep.$(O) : \
1344 $(EMACS_ROOT)/nt/inc/pwd.h \ 1344 $(EMACS_ROOT)/nt/inc/pwd.h \
1345 $(EMACS_ROOT)/nt/inc/unistd.h \ 1345 $(EMACS_ROOT)/nt/inc/unistd.h \
1346 $(EMACS_ROOT)/nt/inc/sys/file.h \ 1346 $(EMACS_ROOT)/nt/inc/sys/file.h \
1347 $(EMACS_ROOT)/nt/inc/sys/ioctl.h \
1348 $(EMACS_ROOT)/nt/inc/sys/socket.h \ 1347 $(EMACS_ROOT)/nt/inc/sys/socket.h \
1349 $(EMACS_ROOT)/nt/inc/sys/time.h \ 1348 $(EMACS_ROOT)/nt/inc/sys/time.h \
1350 $(SRC)/lisp.h \ 1349 $(SRC)/lisp.h \
diff --git a/src/marker.c b/src/marker.c
index b5ea80562df..3f8b78e81a8 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -27,12 +27,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27/* Record one cached position found recently by 27/* Record one cached position found recently by
28 buf_charpos_to_bytepos or buf_bytepos_to_charpos. */ 28 buf_charpos_to_bytepos or buf_bytepos_to_charpos. */
29 29
30static int cached_charpos; 30static EMACS_INT cached_charpos;
31static int cached_bytepos; 31static EMACS_INT cached_bytepos;
32static struct buffer *cached_buffer; 32static struct buffer *cached_buffer;
33static int cached_modiff; 33static int cached_modiff;
34 34
35static void byte_char_debug_check (struct buffer *, int, int); 35static void byte_char_debug_check (struct buffer *, EMACS_INT, EMACS_INT);
36 36
37/* Nonzero means enable debugging checks on byte/char correspondences. */ 37/* Nonzero means enable debugging checks on byte/char correspondences. */
38 38
@@ -60,12 +60,12 @@ clear_charpos_cache (struct buffer *b)
60 60
61#define CONSIDER(CHARPOS, BYTEPOS) \ 61#define CONSIDER(CHARPOS, BYTEPOS) \
62{ \ 62{ \
63 int this_charpos = (CHARPOS); \ 63 EMACS_INT this_charpos = (CHARPOS); \
64 int changed = 0; \ 64 int changed = 0; \
65 \ 65 \
66 if (this_charpos == charpos) \ 66 if (this_charpos == charpos) \
67 { \ 67 { \
68 int value = (BYTEPOS); \ 68 EMACS_INT value = (BYTEPOS); \
69 if (byte_debug_flag) \ 69 if (byte_debug_flag) \
70 byte_char_debug_check (b, charpos, value); \ 70 byte_char_debug_check (b, charpos, value); \
71 return value; \ 71 return value; \
@@ -90,7 +90,7 @@ clear_charpos_cache (struct buffer *b)
90 { \ 90 { \
91 if (best_above - best_below == best_above_byte - best_below_byte) \ 91 if (best_above - best_below == best_above_byte - best_below_byte) \
92 { \ 92 { \
93 int value = best_below_byte + (charpos - best_below); \ 93 EMACS_INT value = best_below_byte + (charpos - best_below); \
94 if (byte_debug_flag) \ 94 if (byte_debug_flag) \
95 byte_char_debug_check (b, charpos, value); \ 95 byte_char_debug_check (b, charpos, value); \
96 return value; \ 96 return value; \
@@ -99,9 +99,9 @@ clear_charpos_cache (struct buffer *b)
99} 99}
100 100
101static void 101static void
102byte_char_debug_check (struct buffer *b, int charpos, int bytepos) 102byte_char_debug_check (struct buffer *b, EMACS_INT charpos, EMACS_INT bytepos)
103{ 103{
104 int nchars = 0; 104 EMACS_INT nchars = 0;
105 105
106 if (bytepos > BUF_GPT_BYTE (b)) 106 if (bytepos > BUF_GPT_BYTE (b))
107 { 107 {
@@ -118,18 +118,18 @@ byte_char_debug_check (struct buffer *b, int charpos, int bytepos)
118 abort (); 118 abort ();
119} 119}
120 120
121int 121EMACS_INT
122charpos_to_bytepos (int charpos) 122charpos_to_bytepos (EMACS_INT charpos)
123{ 123{
124 return buf_charpos_to_bytepos (current_buffer, charpos); 124 return buf_charpos_to_bytepos (current_buffer, charpos);
125} 125}
126 126
127int 127EMACS_INT
128buf_charpos_to_bytepos (struct buffer *b, int charpos) 128buf_charpos_to_bytepos (struct buffer *b, EMACS_INT charpos)
129{ 129{
130 struct Lisp_Marker *tail; 130 struct Lisp_Marker *tail;
131 int best_above, best_above_byte; 131 EMACS_INT best_above, best_above_byte;
132 int best_below, best_below_byte; 132 EMACS_INT best_below, best_below_byte;
133 133
134 if (charpos < BUF_BEG (b) || charpos > BUF_Z (b)) 134 if (charpos < BUF_BEG (b) || charpos > BUF_Z (b))
135 abort (); 135 abort ();
@@ -247,11 +247,11 @@ buf_charpos_to_bytepos (struct buffer *b, int charpos)
247/* Used for debugging: recompute the bytepos corresponding to CHARPOS 247/* Used for debugging: recompute the bytepos corresponding to CHARPOS
248 in the simplest, most reliable way. */ 248 in the simplest, most reliable way. */
249 249
250int 250EMACS_INT
251verify_bytepos (int charpos) 251verify_bytepos (EMACS_INT charpos)
252{ 252{
253 int below = 1; 253 EMACS_INT below = 1;
254 int below_byte = 1; 254 EMACS_INT below_byte = 1;
255 255
256 while (below != charpos) 256 while (below != charpos)
257 { 257 {
@@ -269,12 +269,12 @@ verify_bytepos (int charpos)
269 269
270#define CONSIDER(BYTEPOS, CHARPOS) \ 270#define CONSIDER(BYTEPOS, CHARPOS) \
271{ \ 271{ \
272 int this_bytepos = (BYTEPOS); \ 272 EMACS_INT this_bytepos = (BYTEPOS); \
273 int changed = 0; \ 273 int changed = 0; \
274 \ 274 \
275 if (this_bytepos == bytepos) \ 275 if (this_bytepos == bytepos) \
276 { \ 276 { \
277 int value = (CHARPOS); \ 277 EMACS_INT value = (CHARPOS); \
278 if (byte_debug_flag) \ 278 if (byte_debug_flag) \
279 byte_char_debug_check (b, value, bytepos); \ 279 byte_char_debug_check (b, value, bytepos); \
280 return value; \ 280 return value; \
@@ -299,7 +299,7 @@ verify_bytepos (int charpos)
299 { \ 299 { \
300 if (best_above - best_below == best_above_byte - best_below_byte) \ 300 if (best_above - best_below == best_above_byte - best_below_byte) \
301 { \ 301 { \
302 int value = best_below + (bytepos - best_below_byte); \ 302 EMACS_INT value = best_below + (bytepos - best_below_byte); \
303 if (byte_debug_flag) \ 303 if (byte_debug_flag) \
304 byte_char_debug_check (b, value, bytepos); \ 304 byte_char_debug_check (b, value, bytepos); \
305 return value; \ 305 return value; \
@@ -307,18 +307,18 @@ verify_bytepos (int charpos)
307 } \ 307 } \
308} 308}
309 309
310int 310EMACS_INT
311bytepos_to_charpos (int bytepos) 311bytepos_to_charpos (EMACS_INT bytepos)
312{ 312{
313 return buf_bytepos_to_charpos (current_buffer, bytepos); 313 return buf_bytepos_to_charpos (current_buffer, bytepos);
314} 314}
315 315
316int 316EMACS_INT
317buf_bytepos_to_charpos (struct buffer *b, int bytepos) 317buf_bytepos_to_charpos (struct buffer *b, EMACS_INT bytepos)
318{ 318{
319 struct Lisp_Marker *tail; 319 struct Lisp_Marker *tail;
320 int best_above, best_above_byte; 320 EMACS_INT best_above, best_above_byte;
321 int best_below, best_below_byte; 321 EMACS_INT best_below, best_below_byte;
322 322
323 if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b)) 323 if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b))
324 abort (); 324 abort ();
@@ -470,7 +470,7 @@ Then it no longer slows down editing in any buffer.
470Returns MARKER. */) 470Returns MARKER. */)
471 (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) 471 (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer)
472{ 472{
473 register int charno, bytepos; 473 register EMACS_INT charno, bytepos;
474 register struct buffer *b; 474 register struct buffer *b;
475 register struct Lisp_Marker *m; 475 register struct Lisp_Marker *m;
476 476
@@ -545,7 +545,7 @@ Returns MARKER. */)
545Lisp_Object 545Lisp_Object
546set_marker_restricted (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer) 546set_marker_restricted (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer)
547{ 547{
548 register int charno, bytepos; 548 register EMACS_INT charno, bytepos;
549 register struct buffer *b; 549 register struct buffer *b;
550 register struct Lisp_Marker *m; 550 register struct Lisp_Marker *m;
551 551
@@ -618,7 +618,7 @@ set_marker_restricted (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer)
618 character position and the corresponding byte position. */ 618 character position and the corresponding byte position. */
619 619
620Lisp_Object 620Lisp_Object
621set_marker_both (Lisp_Object marker, Lisp_Object buffer, int charpos, int bytepos) 621set_marker_both (Lisp_Object marker, Lisp_Object buffer, EMACS_INT charpos, EMACS_INT bytepos)
622{ 622{
623 register struct buffer *b; 623 register struct buffer *b;
624 register struct Lisp_Marker *m; 624 register struct Lisp_Marker *m;
@@ -666,7 +666,7 @@ set_marker_both (Lisp_Object marker, Lisp_Object buffer, int charpos, int bytepo
666 be outside the visible part. */ 666 be outside the visible part. */
667 667
668Lisp_Object 668Lisp_Object
669set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, int charpos, int bytepos) 669set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, EMACS_INT charpos, EMACS_INT bytepos)
670{ 670{
671 register struct buffer *b; 671 register struct buffer *b;
672 register struct Lisp_Marker *m; 672 register struct Lisp_Marker *m;
@@ -776,7 +776,7 @@ unchain_marker (register struct Lisp_Marker *marker)
776 776
777/* Return the char position of marker MARKER, as a C integer. */ 777/* Return the char position of marker MARKER, as a C integer. */
778 778
779int 779EMACS_INT
780marker_position (Lisp_Object marker) 780marker_position (Lisp_Object marker)
781{ 781{
782 register struct Lisp_Marker *m = XMARKER (marker); 782 register struct Lisp_Marker *m = XMARKER (marker);
@@ -790,12 +790,12 @@ marker_position (Lisp_Object marker)
790 790
791/* Return the byte position of marker MARKER, as a C integer. */ 791/* Return the byte position of marker MARKER, as a C integer. */
792 792
793int 793EMACS_INT
794marker_byte_position (Lisp_Object marker) 794marker_byte_position (Lisp_Object marker)
795{ 795{
796 register struct Lisp_Marker *m = XMARKER (marker); 796 register struct Lisp_Marker *m = XMARKER (marker);
797 register struct buffer *buf = m->buffer; 797 register struct buffer *buf = m->buffer;
798 register int i = m->bytepos; 798 register EMACS_INT i = m->bytepos;
799 799
800 if (!buf) 800 if (!buf)
801 error ("Marker does not point anywhere"); 801 error ("Marker does not point anywhere");
@@ -856,7 +856,7 @@ DEFUN ("buffer-has-markers-at", Fbuffer_has_markers_at, Sbuffer_has_markers_at,
856 (Lisp_Object position) 856 (Lisp_Object position)
857{ 857{
858 register struct Lisp_Marker *tail; 858 register struct Lisp_Marker *tail;
859 register int charno; 859 register EMACS_INT charno;
860 860
861 charno = XINT (position); 861 charno = XINT (position);
862 862
diff --git a/src/minibuf.c b/src/minibuf.c
index 009d94c36a8..f3a24afc199 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -236,7 +236,7 @@ string_to_object (Lisp_Object val, Lisp_Object defalt)
236{ 236{
237 struct gcpro gcpro1, gcpro2; 237 struct gcpro gcpro1, gcpro2;
238 Lisp_Object expr_and_pos; 238 Lisp_Object expr_and_pos;
239 int pos; 239 EMACS_INT pos;
240 240
241 GCPRO2 (val, defalt); 241 GCPRO2 (val, defalt);
242 242
@@ -254,7 +254,7 @@ string_to_object (Lisp_Object val, Lisp_Object defalt)
254 { 254 {
255 /* Ignore trailing whitespace; any other trailing junk 255 /* Ignore trailing whitespace; any other trailing junk
256 is an error. */ 256 is an error. */
257 int i; 257 EMACS_INT i;
258 pos = string_char_to_byte (val, pos); 258 pos = string_char_to_byte (val, pos);
259 for (i = pos; i < SBYTES (val); i++) 259 for (i = pos; i < SBYTES (val); i++)
260 { 260 {
@@ -370,7 +370,7 @@ DEFUN ("minibuffer-contents", Fminibuffer_contents,
370If the current buffer is not a minibuffer, return its entire contents. */) 370If the current buffer is not a minibuffer, return its entire contents. */)
371 (void) 371 (void)
372{ 372{
373 int prompt_end = XINT (Fminibuffer_prompt_end ()); 373 EMACS_INT prompt_end = XINT (Fminibuffer_prompt_end ());
374 return make_buffer_string (prompt_end, ZV, 1); 374 return make_buffer_string (prompt_end, ZV, 1);
375} 375}
376 376
@@ -380,7 +380,7 @@ DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties,
380If the current buffer is not a minibuffer, return its entire contents. */) 380If the current buffer is not a minibuffer, return its entire contents. */)
381 (void) 381 (void)
382{ 382{
383 int prompt_end = XINT (Fminibuffer_prompt_end ()); 383 EMACS_INT prompt_end = XINT (Fminibuffer_prompt_end ());
384 return make_buffer_string (prompt_end, ZV, 0); 384 return make_buffer_string (prompt_end, ZV, 0);
385} 385}
386 386
@@ -391,7 +391,7 @@ That is what completion commands operate on.
391If the current buffer is not a minibuffer, return its entire contents. */) 391If the current buffer is not a minibuffer, return its entire contents. */)
392 (void) 392 (void)
393{ 393{
394 int prompt_end = XINT (Fminibuffer_prompt_end ()); 394 EMACS_INT prompt_end = XINT (Fminibuffer_prompt_end ());
395 if (PT < prompt_end) 395 if (PT < prompt_end)
396 error ("Cannot do completion in the prompt"); 396 error ("Cannot do completion in the prompt");
397 return make_buffer_string (prompt_end, PT, 1); 397 return make_buffer_string (prompt_end, PT, 1);
diff --git a/src/print.c b/src/print.c
index 91ac68c8d30..d4cbc2ac24a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -96,11 +96,11 @@ Lisp_Object being_printed[PRINT_CIRCLE];
96char *print_buffer; 96char *print_buffer;
97 97
98/* Size allocated in print_buffer. */ 98/* Size allocated in print_buffer. */
99int print_buffer_size; 99EMACS_INT print_buffer_size;
100/* Chars stored in print_buffer. */ 100/* Chars stored in print_buffer. */
101int print_buffer_pos; 101EMACS_INT print_buffer_pos;
102/* Bytes stored in print_buffer. */ 102/* Bytes stored in print_buffer. */
103int print_buffer_pos_byte; 103EMACS_INT print_buffer_pos_byte;
104 104
105/* Maximum length of list to print in full; noninteger means 105/* Maximum length of list to print in full; noninteger means
106 effectively infinity */ 106 effectively infinity */
@@ -177,8 +177,8 @@ int print_output_debug_flag = 1;
177 177
178#define PRINTDECLARE \ 178#define PRINTDECLARE \
179 struct buffer *old = current_buffer; \ 179 struct buffer *old = current_buffer; \
180 int old_point = -1, start_point = -1; \ 180 EMACS_INT old_point = -1, start_point = -1; \
181 int old_point_byte = -1, start_point_byte = -1; \ 181 EMACS_INT old_point_byte = -1, start_point_byte = -1; \
182 int specpdl_count = SPECPDL_INDEX (); \ 182 int specpdl_count = SPECPDL_INDEX (); \
183 int free_print_buffer = 0; \ 183 int free_print_buffer = 0; \
184 int multibyte = !NILP (current_buffer->enable_multibyte_characters); \ 184 int multibyte = !NILP (current_buffer->enable_multibyte_characters); \
@@ -342,8 +342,8 @@ printchar (unsigned int ch, Lisp_Object fun)
342 to data in a Lisp string. Otherwise that is not safe. */ 342 to data in a Lisp string. Otherwise that is not safe. */
343 343
344static void 344static void
345strout (const char *ptr, int size, int size_byte, Lisp_Object printcharfun, 345strout (const char *ptr, EMACS_INT size, EMACS_INT size_byte,
346 int multibyte) 346 Lisp_Object printcharfun, int multibyte)
347{ 347{
348 if (size < 0) 348 if (size < 0)
349 size_byte = size = strlen (ptr); 349 size_byte = size = strlen (ptr);
@@ -395,7 +395,7 @@ strout (const char *ptr, int size, int size_byte, Lisp_Object printcharfun,
395 else 395 else
396 { 396 {
397 /* PRINTCHARFUN is a Lisp function. */ 397 /* PRINTCHARFUN is a Lisp function. */
398 int i = 0; 398 EMACS_INT i = 0;
399 399
400 if (size == size_byte) 400 if (size == size_byte)
401 { 401 {
@@ -430,7 +430,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
430{ 430{
431 if (EQ (printcharfun, Qt) || NILP (printcharfun)) 431 if (EQ (printcharfun, Qt) || NILP (printcharfun))
432 { 432 {
433 int chars; 433 EMACS_INT chars;
434 434
435 if (print_escape_nonascii) 435 if (print_escape_nonascii)
436 string = string_escape_byte8 (string); 436 string = string_escape_byte8 (string);
@@ -446,7 +446,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
446 convert STRING to a multibyte string containing the same 446 convert STRING to a multibyte string containing the same
447 character codes. */ 447 character codes. */
448 Lisp_Object newstr; 448 Lisp_Object newstr;
449 int bytes; 449 EMACS_INT bytes;
450 450
451 chars = SBYTES (string); 451 chars = SBYTES (string);
452 bytes = parse_str_to_multibyte (SDATA (string), chars); 452 bytes = parse_str_to_multibyte (SDATA (string), chars);
@@ -464,7 +464,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
464 if (EQ (printcharfun, Qt)) 464 if (EQ (printcharfun, Qt))
465 { 465 {
466 /* Output to echo area. */ 466 /* Output to echo area. */
467 int nbytes = SBYTES (string); 467 EMACS_INT nbytes = SBYTES (string);
468 char *buffer; 468 char *buffer;
469 469
470 /* Copy the string contents so that relocation of STRING by 470 /* Copy the string contents so that relocation of STRING by
@@ -489,9 +489,9 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
489 { 489 {
490 /* Otherwise, string may be relocated by printing one char. 490 /* Otherwise, string may be relocated by printing one char.
491 So re-fetch the string address for each character. */ 491 So re-fetch the string address for each character. */
492 int i; 492 EMACS_INT i;
493 int size = SCHARS (string); 493 EMACS_INT size = SCHARS (string);
494 int size_byte = SBYTES (string); 494 EMACS_INT size_byte = SBYTES (string);
495 struct gcpro gcpro1; 495 struct gcpro gcpro1;
496 GCPRO1 (string); 496 GCPRO1 (string);
497 if (size == size_byte) 497 if (size == size_byte)
@@ -868,7 +868,7 @@ to make it write to the debugging output. */)
868 (Lisp_Object character) 868 (Lisp_Object character)
869{ 869{
870 CHECK_NUMBER (character); 870 CHECK_NUMBER (character);
871 putc (XINT (character), stderr); 871 putc ((int) XINT (character), stderr);
872 872
873#ifdef WINDOWSNT 873#ifdef WINDOWSNT
874 /* Send the output to a debugger (nothing happens if there isn't one). */ 874 /* Send the output to a debugger (nothing happens if there isn't one). */
@@ -1430,8 +1430,8 @@ print_check_string_charset_prop (INTERVAL interval, Lisp_Object string)
1430 || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) 1430 || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
1431 { 1431 {
1432 int i, c; 1432 int i, c;
1433 int charpos = interval->position; 1433 EMACS_INT charpos = interval->position;
1434 int bytepos = string_char_to_byte (string, charpos); 1434 EMACS_INT bytepos = string_char_to_byte (string, charpos);
1435 Lisp_Object charset; 1435 Lisp_Object charset;
1436 1436
1437 charset = XCAR (XCDR (val)); 1437 charset = XCAR (XCDR (val));
@@ -1563,10 +1563,10 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1563 print_string (obj, printcharfun); 1563 print_string (obj, printcharfun);
1564 else 1564 else
1565 { 1565 {
1566 register int i, i_byte; 1566 register EMACS_INT i, i_byte;
1567 struct gcpro gcpro1; 1567 struct gcpro gcpro1;
1568 unsigned char *str; 1568 unsigned char *str;
1569 int size_byte; 1569 EMACS_INT size_byte;
1570 /* 1 means we must ensure that the next character we output 1570 /* 1 means we must ensure that the next character we output
1571 cannot be taken as part of a hex character escape. */ 1571 cannot be taken as part of a hex character escape. */
1572 int need_nonhex = 0; 1572 int need_nonhex = 0;
@@ -1684,7 +1684,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1684 register unsigned char *p = SDATA (SYMBOL_NAME (obj)); 1684 register unsigned char *p = SDATA (SYMBOL_NAME (obj));
1685 register unsigned char *end = p + SBYTES (SYMBOL_NAME (obj)); 1685 register unsigned char *end = p + SBYTES (SYMBOL_NAME (obj));
1686 register int c; 1686 register int c;
1687 int i, i_byte, size_byte; 1687 int i, i_byte;
1688 EMACS_INT size_byte;
1688 Lisp_Object name; 1689 Lisp_Object name;
1689 1690
1690 name = SYMBOL_NAME (obj); 1691 name = SYMBOL_NAME (obj);
@@ -1803,7 +1804,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1803 } 1804 }
1804 1805
1805 { 1806 {
1806 int print_length, i; 1807 EMACS_INT print_length;
1808 int i;
1807 Lisp_Object halftail = obj; 1809 Lisp_Object halftail = obj;
1808 1810
1809 /* Negative values of print-length are invalid in CL. 1811 /* Negative values of print-length are invalid in CL.
@@ -1898,7 +1900,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1898 register int i; 1900 register int i;
1899 register unsigned char c; 1901 register unsigned char c;
1900 struct gcpro gcpro1; 1902 struct gcpro gcpro1;
1901 int size_in_chars 1903 EMACS_INT size_in_chars
1902 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) 1904 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
1903 / BOOL_VECTOR_BITS_PER_CHAR); 1905 / BOOL_VECTOR_BITS_PER_CHAR);
1904 1906
@@ -1984,7 +1986,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1984 else if (HASH_TABLE_P (obj)) 1986 else if (HASH_TABLE_P (obj))
1985 { 1987 {
1986 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); 1988 struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
1987 int i, real_size, size; 1989 int i;
1990 EMACS_INT real_size, size;
1988#if 0 1991#if 0
1989 strout ("#<hash-table", -1, -1, printcharfun, 0); 1992 strout ("#<hash-table", -1, -1, printcharfun, 0);
1990 if (SYMBOLP (h->test)) 1993 if (SYMBOLP (h->test))
@@ -2150,7 +2153,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2150 { 2153 {
2151 register int i; 2154 register int i;
2152 register Lisp_Object tem; 2155 register Lisp_Object tem;
2153 int real_size = size; 2156 EMACS_INT real_size = size;
2154 2157
2155 /* Don't print more elements than the specified maximum. */ 2158 /* Don't print more elements than the specified maximum. */
2156 if (NATNUMP (Vprint_length) 2159 if (NATNUMP (Vprint_length)
@@ -2182,7 +2185,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2182 strout ("in no buffer", -1, -1, printcharfun, 0); 2185 strout ("in no buffer", -1, -1, printcharfun, 0);
2183 else 2186 else
2184 { 2187 {
2185 sprintf (buf, "at %d", marker_position (obj)); 2188 sprintf (buf, "at %ld", (long)marker_position (obj));
2186 strout (buf, -1, -1, printcharfun, 0); 2189 strout (buf, -1, -1, printcharfun, 0);
2187 strout (" in ", -1, -1, printcharfun, 0); 2190 strout (" in ", -1, -1, printcharfun, 0);
2188 print_string (XMARKER (obj)->buffer->name, printcharfun); 2191 print_string (XMARKER (obj)->buffer->name, printcharfun);
@@ -2196,9 +2199,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2196 strout ("in no buffer", -1, -1, printcharfun, 0); 2199 strout ("in no buffer", -1, -1, printcharfun, 0);
2197 else 2200 else
2198 { 2201 {
2199 sprintf (buf, "from %d to %d in ", 2202 sprintf (buf, "from %ld to %ld in ",
2200 marker_position (OVERLAY_START (obj)), 2203 (long)marker_position (OVERLAY_START (obj)),
2201 marker_position (OVERLAY_END (obj))); 2204 (long)marker_position (OVERLAY_END (obj)));
2202 strout (buf, -1, -1, printcharfun, 0); 2205 strout (buf, -1, -1, printcharfun, 0);
2203 print_string (XMARKER (OVERLAY_START (obj))->buffer->name, 2206 print_string (XMARKER (OVERLAY_START (obj))->buffer->name,
2204 printcharfun); 2207 printcharfun);
diff --git a/src/process.c b/src/process.c
index f348dca7d35..a698e56fe39 100644
--- a/src/process.c
+++ b/src/process.c
@@ -105,6 +105,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
105#include "sysselect.h" 105#include "sysselect.h"
106#include "syssignal.h" 106#include "syssignal.h"
107#include "syswait.h" 107#include "syswait.h"
108#ifdef HAVE_GNUTLS
109#include "gnutls.h"
110#endif
108 111
109#if defined (USE_GTK) || defined (HAVE_GCONF) 112#if defined (USE_GTK) || defined (HAVE_GCONF)
110#include "xgselect.h" 113#include "xgselect.h"
@@ -198,8 +201,10 @@ int update_tick;
198 201
199/* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */ 202/* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */
200 203
204/* Only W32 has this, it really means that select can't take write mask. */
201#ifdef BROKEN_NON_BLOCKING_CONNECT 205#ifdef BROKEN_NON_BLOCKING_CONNECT
202#undef NON_BLOCKING_CONNECT 206#undef NON_BLOCKING_CONNECT
207#define SELECT_CANT_DO_WRITE_MASK
203#else 208#else
204#ifndef NON_BLOCKING_CONNECT 209#ifndef NON_BLOCKING_CONNECT
205#ifdef HAVE_SELECT 210#ifdef HAVE_SELECT
@@ -291,9 +296,9 @@ static SELECT_TYPE non_keyboard_wait_mask;
291 296
292static SELECT_TYPE non_process_wait_mask; 297static SELECT_TYPE non_process_wait_mask;
293 298
294/* Mask for the gpm mouse input descriptor. */ 299/* Mask for selecting for write. */
295 300
296static SELECT_TYPE gpm_wait_mask; 301static SELECT_TYPE write_mask;
297 302
298#ifdef NON_BLOCKING_CONNECT 303#ifdef NON_BLOCKING_CONNECT
299/* Mask of bits indicating the descriptors that we wait for connect to 304/* Mask of bits indicating the descriptors that we wait for connect to
@@ -313,11 +318,8 @@ static int num_pending_connects;
313/* The largest descriptor currently in use for a process object. */ 318/* The largest descriptor currently in use for a process object. */
314static int max_process_desc; 319static int max_process_desc;
315 320
316/* The largest descriptor currently in use for keyboard input. */ 321/* The largest descriptor currently in use for input. */
317static int max_keyboard_desc; 322static int max_input_desc;
318
319/* The largest descriptor currently in use for gpm mouse input. */
320static int max_gpm_desc;
321 323
322/* Indexed by descriptor, gives the process (if any) for that descriptor */ 324/* Indexed by descriptor, gives the process (if any) for that descriptor */
323Lisp_Object chan_process[MAXDESC]; 325Lisp_Object chan_process[MAXDESC];
@@ -363,6 +365,90 @@ static int pty_max_bytes;
363static char pty_name[24]; 365static char pty_name[24];
364#endif 366#endif
365 367
368
369struct fd_callback_data
370{
371 fd_callback func;
372 void *data;
373#define FOR_READ 1
374#define FOR_WRITE 2
375 int condition; /* mask of the defines above. */
376} fd_callback_info[MAXDESC];
377
378
379/* Add a file descriptor FD to be monitored for when read is possible.
380 When read is possible, call FUNC with argument DATA. */
381
382void
383add_read_fd (int fd, fd_callback func, void *data)
384{
385 xassert (fd < MAXDESC);
386 add_keyboard_wait_descriptor (fd);
387
388 fd_callback_info[fd].func = func;
389 fd_callback_info[fd].data = data;
390 fd_callback_info[fd].condition |= FOR_READ;
391}
392
393/* Stop monitoring file descriptor FD for when read is possible. */
394
395void
396delete_read_fd (int fd)
397{
398 xassert (fd < MAXDESC);
399 delete_keyboard_wait_descriptor (fd);
400
401 fd_callback_info[fd].condition &= ~FOR_READ;
402 if (fd_callback_info[fd].condition == 0)
403 {
404 fd_callback_info[fd].func = 0;
405 fd_callback_info[fd].data = 0;
406 }
407}
408
409/* Add a file descriptor FD to be monitored for when write is possible.
410 When write is possible, call FUNC with argument DATA. */
411
412void
413add_write_fd (int fd, fd_callback func, void *data)
414{
415 xassert (fd < MAXDESC);
416 FD_SET (fd, &write_mask);
417 if (fd > max_input_desc)
418 max_input_desc = fd;
419
420 fd_callback_info[fd].func = func;
421 fd_callback_info[fd].data = data;
422 fd_callback_info[fd].condition |= FOR_WRITE;
423}
424
425/* Stop monitoring file descriptor FD for when write is possible. */
426
427void
428delete_write_fd (int fd)
429{
430 int lim = max_input_desc;
431
432 xassert (fd < MAXDESC);
433 FD_CLR (fd, &write_mask);
434 fd_callback_info[fd].condition &= ~FOR_WRITE;
435 if (fd_callback_info[fd].condition == 0)
436 {
437 fd_callback_info[fd].func = 0;
438 fd_callback_info[fd].data = 0;
439
440 if (fd == max_input_desc)
441 for (fd = lim; fd >= 0; fd--)
442 if (FD_ISSET (fd, &input_wait_mask) || FD_ISSET (fd, &write_mask))
443 {
444 max_input_desc = fd;
445 break;
446 }
447
448 }
449}
450
451
366/* Compute the Lisp form of the process status, p->status, from 452/* Compute the Lisp form of the process status, p->status, from
367 the numeric status that was returned by `wait'. */ 453 the numeric status that was returned by `wait'. */
368 454
@@ -583,6 +669,12 @@ make_process (Lisp_Object name)
583 p->read_output_skip = 0; 669 p->read_output_skip = 0;
584#endif 670#endif
585 671
672#ifdef HAVE_GNUTLS
673 p->gnutls_initstage = GNUTLS_STAGE_EMPTY;
674 p->gnutls_log_level = 0;
675 p->gnutls_p = 0;
676#endif
677
586 /* If name is already in use, modify it until it is unused. */ 678 /* If name is already in use, modify it until it is unused. */
587 679
588 name1 = name; 680 name1 = name;
@@ -1526,6 +1618,12 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1526 XPROCESS (proc)->filter = Qnil; 1618 XPROCESS (proc)->filter = Qnil;
1527 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); 1619 XPROCESS (proc)->command = Flist (nargs - 2, args + 2);
1528 1620
1621#ifdef HAVE_GNUTLS
1622 /* AKA GNUTLS_INITSTAGE(proc). */
1623 XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY;
1624 XPROCESS (proc)->gnutls_cred_type = Qnil;
1625#endif
1626
1529#ifdef ADAPTIVE_READ_BUFFERING 1627#ifdef ADAPTIVE_READ_BUFFERING
1530 XPROCESS (proc)->adaptive_read_buffering 1628 XPROCESS (proc)->adaptive_read_buffering
1531 = (NILP (Vprocess_adaptive_read_buffering) ? 0 1629 = (NILP (Vprocess_adaptive_read_buffering) ? 0
@@ -3170,7 +3268,9 @@ usage: (make-network-process &rest ARGS) */)
3170 if (!NILP (host)) 3268 if (!NILP (host))
3171 { 3269 {
3172 if (EQ (host, Qlocal)) 3270 if (EQ (host, Qlocal))
3173 host = build_string ("localhost"); 3271 /* Depending on setup, "localhost" may map to different IPv4 and/or
3272 IPv6 addresses, so it's better to be explicit. (Bug#6781) */
3273 host = build_string ("127.0.0.1");
3174 CHECK_STRING (host); 3274 CHECK_STRING (host);
3175 } 3275 }
3176 3276
@@ -3605,6 +3705,7 @@ usage: (make-network-process &rest ARGS) */)
3605 if (!FD_ISSET (inch, &connect_wait_mask)) 3705 if (!FD_ISSET (inch, &connect_wait_mask))
3606 { 3706 {
3607 FD_SET (inch, &connect_wait_mask); 3707 FD_SET (inch, &connect_wait_mask);
3708 FD_SET (inch, &write_mask);
3608 num_pending_connects++; 3709 num_pending_connects++;
3609 } 3710 }
3610 } 3711 }
@@ -4008,6 +4109,7 @@ deactivate_process (Lisp_Object proc)
4008 if (FD_ISSET (inchannel, &connect_wait_mask)) 4109 if (FD_ISSET (inchannel, &connect_wait_mask))
4009 { 4110 {
4010 FD_CLR (inchannel, &connect_wait_mask); 4111 FD_CLR (inchannel, &connect_wait_mask);
4112 FD_CLR (inchannel, &write_mask);
4011 if (--num_pending_connects < 0) 4113 if (--num_pending_connects < 0)
4012 abort (); 4114 abort ();
4013 } 4115 }
@@ -4386,10 +4488,8 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4386{ 4488{
4387 register int channel, nfds; 4489 register int channel, nfds;
4388 SELECT_TYPE Available; 4490 SELECT_TYPE Available;
4389#ifdef NON_BLOCKING_CONNECT 4491 SELECT_TYPE Writeok;
4390 SELECT_TYPE Connecting; 4492 int check_write;
4391 int check_connect;
4392#endif
4393 int check_delay, no_avail; 4493 int check_delay, no_avail;
4394 int xerrno; 4494 int xerrno;
4395 Lisp_Object proc; 4495 Lisp_Object proc;
@@ -4399,11 +4499,9 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4399 int count = SPECPDL_INDEX (); 4499 int count = SPECPDL_INDEX ();
4400 4500
4401 FD_ZERO (&Available); 4501 FD_ZERO (&Available);
4402#ifdef NON_BLOCKING_CONNECT 4502 FD_ZERO (&Writeok);
4403 FD_ZERO (&Connecting);
4404#endif
4405 4503
4406 if (time_limit == 0 && wait_proc && !NILP (Vinhibit_quit) 4504 if (time_limit == 0 && microsecs == 0 && wait_proc && !NILP (Vinhibit_quit)
4407 && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit))) 4505 && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit)))
4408 message ("Blocking call to accept-process-output with quit inhibited!!"); 4506 message ("Blocking call to accept-process-output with quit inhibited!!");
4409 4507
@@ -4537,19 +4635,16 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4537 if (update_tick != process_tick) 4635 if (update_tick != process_tick)
4538 { 4636 {
4539 SELECT_TYPE Atemp; 4637 SELECT_TYPE Atemp;
4540#ifdef NON_BLOCKING_CONNECT
4541 SELECT_TYPE Ctemp; 4638 SELECT_TYPE Ctemp;
4542#endif
4543 4639
4544 if (kbd_on_hold_p ()) 4640 if (kbd_on_hold_p ())
4545 FD_ZERO (&Atemp); 4641 FD_ZERO (&Atemp);
4546 else 4642 else
4547 Atemp = input_wait_mask; 4643 Atemp = input_wait_mask;
4548 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); 4644 Ctemp = write_mask;
4549 4645
4550 EMACS_SET_SECS_USECS (timeout, 0, 0); 4646 EMACS_SET_SECS_USECS (timeout, 0, 0);
4551 if ((select (max (max (max_process_desc, max_keyboard_desc), 4647 if ((select (max (max_process_desc, max_input_desc) + 1,
4552 max_gpm_desc) + 1,
4553 &Atemp, 4648 &Atemp,
4554#ifdef NON_BLOCKING_CONNECT 4649#ifdef NON_BLOCKING_CONNECT
4555 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), 4650 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
@@ -4620,13 +4715,13 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4620 break; 4715 break;
4621 FD_SET (wait_proc->infd, &Available); 4716 FD_SET (wait_proc->infd, &Available);
4622 check_delay = 0; 4717 check_delay = 0;
4623 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4718 check_write = 0;
4624 } 4719 }
4625 else if (!NILP (wait_for_cell)) 4720 else if (!NILP (wait_for_cell))
4626 { 4721 {
4627 Available = non_process_wait_mask; 4722 Available = non_process_wait_mask;
4628 check_delay = 0; 4723 check_delay = 0;
4629 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4724 check_write = 0;
4630 } 4725 }
4631 else 4726 else
4632 { 4727 {
@@ -4634,7 +4729,12 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4634 Available = non_keyboard_wait_mask; 4729 Available = non_keyboard_wait_mask;
4635 else 4730 else
4636 Available = input_wait_mask; 4731 Available = input_wait_mask;
4637 IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0)); 4732 Writeok = write_mask;
4733#ifdef SELECT_CANT_DO_WRITE_MASK
4734 check_write = 0;
4735#else
4736 check_write = 1;
4737#endif
4638 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; 4738 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count;
4639 } 4739 }
4640 4740
@@ -4659,10 +4759,6 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4659 } 4759 }
4660 else 4760 else
4661 { 4761 {
4662#ifdef NON_BLOCKING_CONNECT
4663 if (check_connect)
4664 Connecting = connect_wait_mask;
4665#endif
4666 4762
4667#ifdef ADAPTIVE_READ_BUFFERING 4763#ifdef ADAPTIVE_READ_BUFFERING
4668 /* Set the timeout for adaptive read buffering if any 4764 /* Set the timeout for adaptive read buffering if any
@@ -4704,15 +4800,10 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4704#else 4800#else
4705 nfds = select 4801 nfds = select
4706#endif 4802#endif
4707 (max (max (max_process_desc, max_keyboard_desc), 4803 (max (max_process_desc, max_input_desc) + 1,
4708 max_gpm_desc) + 1, 4804 &Available,
4709 &Available, 4805 (check_write ? &Writeok : (SELECT_TYPE *)0),
4710#ifdef NON_BLOCKING_CONNECT 4806 (SELECT_TYPE *)0, &timeout);
4711 (check_connect ? &Connecting : (SELECT_TYPE *)0),
4712#else
4713 (SELECT_TYPE *)0,
4714#endif
4715 (SELECT_TYPE *)0, &timeout);
4716 } 4807 }
4717 4808
4718 xerrno = errno; 4809 xerrno = errno;
@@ -4752,7 +4843,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4752 if (no_avail) 4843 if (no_avail)
4753 { 4844 {
4754 FD_ZERO (&Available); 4845 FD_ZERO (&Available);
4755 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4846 check_write = 0;
4756 } 4847 }
4757 4848
4758#if 0 /* When polling is used, interrupt_input is 0, 4849#if 0 /* When polling is used, interrupt_input is 0,
@@ -4848,12 +4939,26 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4848 if (no_avail || nfds == 0) 4939 if (no_avail || nfds == 0)
4849 continue; 4940 continue;
4850 4941
4942 for (channel = 0; channel <= max_input_desc; ++channel)
4943 {
4944 struct fd_callback_data *d = &fd_callback_info[channel];
4945 if (FD_ISSET (channel, &Available)
4946 && d->func != 0
4947 && (d->condition & FOR_READ) != 0)
4948 d->func (channel, d->data, 1);
4949 if (FD_ISSET (channel, &write_mask)
4950 && d->func != 0
4951 && (d->condition & FOR_WRITE) != 0)
4952 d->func (channel, d->data, 0);
4953 }
4954
4851 /* Really FIRST_PROC_DESC should be 0 on Unix, 4955 /* Really FIRST_PROC_DESC should be 0 on Unix,
4852 but this is safer in the short run. */ 4956 but this is safer in the short run. */
4853 for (channel = 0; channel <= max_process_desc; channel++) 4957 for (channel = 0; channel <= max_process_desc; channel++)
4854 { 4958 {
4855 if (FD_ISSET (channel, &Available) 4959 if (FD_ISSET (channel, &Available)
4856 && FD_ISSET (channel, &non_keyboard_wait_mask)) 4960 && FD_ISSET (channel, &non_keyboard_wait_mask)
4961 && !FD_ISSET (channel, &non_process_wait_mask))
4857 { 4962 {
4858 int nread; 4963 int nread;
4859 4964
@@ -4958,12 +5063,13 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4958 } 5063 }
4959 } 5064 }
4960#ifdef NON_BLOCKING_CONNECT 5065#ifdef NON_BLOCKING_CONNECT
4961 if (check_connect && FD_ISSET (channel, &Connecting) 5066 if (FD_ISSET (channel, &Writeok)
4962 && FD_ISSET (channel, &connect_wait_mask)) 5067 && FD_ISSET (channel, &connect_wait_mask))
4963 { 5068 {
4964 struct Lisp_Process *p; 5069 struct Lisp_Process *p;
4965 5070
4966 FD_CLR (channel, &connect_wait_mask); 5071 FD_CLR (channel, &connect_wait_mask);
5072 FD_CLR (channel, &write_mask);
4967 if (--num_pending_connects < 0) 5073 if (--num_pending_connects < 0)
4968 abort (); 5074 abort ();
4969 5075
@@ -5073,7 +5179,7 @@ read_process_output (Lisp_Object proc, register int channel)
5073 char *chars; 5179 char *chars;
5074 register Lisp_Object outstream; 5180 register Lisp_Object outstream;
5075 register struct Lisp_Process *p = XPROCESS (proc); 5181 register struct Lisp_Process *p = XPROCESS (proc);
5076 register int opoint; 5182 register EMACS_INT opoint;
5077 struct coding_system *coding = proc_decode_coding_system[channel]; 5183 struct coding_system *coding = proc_decode_coding_system[channel];
5078 int carryover = p->decoding_carryover; 5184 int carryover = p->decoding_carryover;
5079 int readmax = 4096; 5185 int readmax = 4096;
@@ -5097,7 +5203,13 @@ read_process_output (Lisp_Object proc, register int channel)
5097#endif 5203#endif
5098 if (proc_buffered_char[channel] < 0) 5204 if (proc_buffered_char[channel] < 0)
5099 { 5205 {
5100 nbytes = emacs_read (channel, chars + carryover, readmax); 5206#ifdef HAVE_GNUTLS
5207 if (XPROCESS (proc)->gnutls_p)
5208 nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
5209 chars + carryover, readmax);
5210 else
5211#endif
5212 nbytes = emacs_read (channel, chars + carryover, readmax);
5101#ifdef ADAPTIVE_READ_BUFFERING 5213#ifdef ADAPTIVE_READ_BUFFERING
5102 if (nbytes > 0 && p->adaptive_read_buffering) 5214 if (nbytes > 0 && p->adaptive_read_buffering)
5103 { 5215 {
@@ -5130,7 +5242,13 @@ read_process_output (Lisp_Object proc, register int channel)
5130 { 5242 {
5131 chars[carryover] = proc_buffered_char[channel]; 5243 chars[carryover] = proc_buffered_char[channel];
5132 proc_buffered_char[channel] = -1; 5244 proc_buffered_char[channel] = -1;
5133 nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1); 5245#ifdef HAVE_GNUTLS
5246 if (XPROCESS (proc)->gnutls_p)
5247 nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
5248 chars + carryover + 1, readmax - 1);
5249 else
5250#endif
5251 nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
5134 if (nbytes < 0) 5252 if (nbytes < 0)
5135 nbytes = 1; 5253 nbytes = 1;
5136 else 5254 else
@@ -5263,10 +5381,10 @@ read_process_output (Lisp_Object proc, register int channel)
5263 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) 5381 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
5264 { 5382 {
5265 Lisp_Object old_read_only; 5383 Lisp_Object old_read_only;
5266 int old_begv, old_zv; 5384 EMACS_INT old_begv, old_zv;
5267 int old_begv_byte, old_zv_byte; 5385 EMACS_INT old_begv_byte, old_zv_byte;
5268 int before, before_byte; 5386 EMACS_INT before, before_byte;
5269 int opoint_byte; 5387 EMACS_INT opoint_byte;
5270 Lisp_Object text; 5388 Lisp_Object text;
5271 struct buffer *b; 5389 struct buffer *b;
5272 5390
@@ -5403,11 +5521,11 @@ send_process_trap (int ignore)
5403 5521
5404static void 5522static void
5405send_process (volatile Lisp_Object proc, const unsigned char *volatile buf, 5523send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5406 volatile int len, volatile Lisp_Object object) 5524 volatile EMACS_INT len, volatile Lisp_Object object)
5407{ 5525{
5408 /* Use volatile to protect variables from being clobbered by longjmp. */ 5526 /* Use volatile to protect variables from being clobbered by longjmp. */
5409 struct Lisp_Process *p = XPROCESS (proc); 5527 struct Lisp_Process *p = XPROCESS (proc);
5410 int rv; 5528 EMACS_INT rv;
5411 struct coding_system *coding; 5529 struct coding_system *coding;
5412 struct gcpro gcpro1; 5530 struct gcpro gcpro1;
5413 SIGTYPE (*volatile old_sigpipe) (int); 5531 SIGTYPE (*volatile old_sigpipe) (int);
@@ -5464,8 +5582,8 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5464 coding->dst_object = Qt; 5582 coding->dst_object = Qt;
5465 if (BUFFERP (object)) 5583 if (BUFFERP (object))
5466 { 5584 {
5467 int from_byte, from, to; 5585 EMACS_INT from_byte, from, to;
5468 int save_pt, save_pt_byte; 5586 EMACS_INT save_pt, save_pt_byte;
5469 struct buffer *cur = current_buffer; 5587 struct buffer *cur = current_buffer;
5470 5588
5471 set_buffer_internal (XBUFFER (object)); 5589 set_buffer_internal (XBUFFER (object));
@@ -5517,7 +5635,7 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5517 process_sent_to = proc; 5635 process_sent_to = proc;
5518 while (len > 0) 5636 while (len > 0)
5519 { 5637 {
5520 int this = len; 5638 EMACS_INT this = len;
5521 5639
5522 /* Send this batch, using one or more write calls. */ 5640 /* Send this batch, using one or more write calls. */
5523 while (this > 0) 5641 while (this > 0)
@@ -5540,7 +5658,14 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5540 else 5658 else
5541#endif 5659#endif
5542 { 5660 {
5543 rv = emacs_write (outfd, (char *) buf, this); 5661#ifdef HAVE_GNUTLS
5662 if (XPROCESS (proc)->gnutls_p)
5663 rv = emacs_gnutls_write (outfd,
5664 XPROCESS (proc),
5665 (char *) buf, this);
5666 else
5667#endif
5668 rv = emacs_write (outfd, (char *) buf, this);
5544#ifdef ADAPTIVE_READ_BUFFERING 5669#ifdef ADAPTIVE_READ_BUFFERING
5545 if (p->read_output_delay > 0 5670 if (p->read_output_delay > 0
5546 && p->adaptive_read_buffering == 1) 5671 && p->adaptive_read_buffering == 1)
@@ -5651,7 +5776,7 @@ Output from processes can arrive in between bunches. */)
5651 (Lisp_Object process, Lisp_Object start, Lisp_Object end) 5776 (Lisp_Object process, Lisp_Object start, Lisp_Object end)
5652{ 5777{
5653 Lisp_Object proc; 5778 Lisp_Object proc;
5654 int start1, end1; 5779 EMACS_INT start1, end1;
5655 5780
5656 proc = get_process (process); 5781 proc = get_process (process);
5657 validate_region (&start, &end); 5782 validate_region (&start, &end);
@@ -6592,8 +6717,8 @@ status_notify (struct Lisp_Process *deleting_process)
6592 { 6717 {
6593 Lisp_Object tem; 6718 Lisp_Object tem;
6594 struct buffer *old = current_buffer; 6719 struct buffer *old = current_buffer;
6595 int opoint, opoint_byte; 6720 EMACS_INT opoint, opoint_byte;
6596 int before, before_byte; 6721 EMACS_INT before, before_byte;
6597 6722
6598 /* Avoid error if buffer is deleted 6723 /* Avoid error if buffer is deleted
6599 (probably that's why the process is dead, too) */ 6724 (probably that's why the process is dead, too) */
@@ -6711,35 +6836,16 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6711 6836
6712 6837
6713 6838
6714static int add_gpm_wait_descriptor_called_flag;
6715
6716void 6839void
6717add_gpm_wait_descriptor (int desc) 6840add_gpm_wait_descriptor (int desc)
6718{ 6841{
6719 if (! add_gpm_wait_descriptor_called_flag) 6842 add_keyboard_wait_descriptor (desc);
6720 FD_CLR (0, &input_wait_mask);
6721 add_gpm_wait_descriptor_called_flag = 1;
6722 FD_SET (desc, &input_wait_mask);
6723 FD_SET (desc, &gpm_wait_mask);
6724 if (desc > max_gpm_desc)
6725 max_gpm_desc = desc;
6726} 6843}
6727 6844
6728void 6845void
6729delete_gpm_wait_descriptor (int desc) 6846delete_gpm_wait_descriptor (int desc)
6730{ 6847{
6731 int fd; 6848 delete_keyboard_wait_descriptor (desc);
6732 int lim = max_gpm_desc;
6733
6734 FD_CLR (desc, &input_wait_mask);
6735 FD_CLR (desc, &non_process_wait_mask);
6736
6737 if (desc == max_gpm_desc)
6738 for (fd = 0; fd < lim; fd++)
6739 if (FD_ISSET (fd, &input_wait_mask)
6740 && !FD_ISSET (fd, &non_keyboard_wait_mask)
6741 && !FD_ISSET (fd, &non_process_wait_mask))
6742 max_gpm_desc = fd;
6743} 6849}
6744 6850
6745/* Return nonzero if *MASK has a bit set 6851/* Return nonzero if *MASK has a bit set
@@ -6750,7 +6856,7 @@ keyboard_bit_set (fd_set *mask)
6750{ 6856{
6751 int fd; 6857 int fd;
6752 6858
6753 for (fd = 0; fd <= max_keyboard_desc; fd++) 6859 for (fd = 0; fd <= max_input_desc; fd++)
6754 if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask) 6860 if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask)
6755 && !FD_ISSET (fd, &non_keyboard_wait_mask)) 6861 && !FD_ISSET (fd, &non_keyboard_wait_mask))
6756 return 1; 6862 return 1;
@@ -6989,11 +7095,11 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
6989void 7095void
6990add_keyboard_wait_descriptor (int desc) 7096add_keyboard_wait_descriptor (int desc)
6991{ 7097{
6992#ifdef subprocesses 7098#ifdef subprocesses /* actually means "not MSDOS" */
6993 FD_SET (desc, &input_wait_mask); 7099 FD_SET (desc, &input_wait_mask);
6994 FD_SET (desc, &non_process_wait_mask); 7100 FD_SET (desc, &non_process_wait_mask);
6995 if (desc > max_keyboard_desc) 7101 if (desc > max_input_desc)
6996 max_keyboard_desc = desc; 7102 max_input_desc = desc;
6997#endif 7103#endif
6998} 7104}
6999 7105
@@ -7004,18 +7110,16 @@ delete_keyboard_wait_descriptor (int desc)
7004{ 7110{
7005#ifdef subprocesses 7111#ifdef subprocesses
7006 int fd; 7112 int fd;
7007 int lim = max_keyboard_desc; 7113 int lim = max_input_desc;
7008 7114
7009 FD_CLR (desc, &input_wait_mask); 7115 FD_CLR (desc, &input_wait_mask);
7010 FD_CLR (desc, &non_process_wait_mask); 7116 FD_CLR (desc, &non_process_wait_mask);
7011 7117
7012 if (desc == max_keyboard_desc) 7118 if (desc == max_input_desc)
7013 for (fd = 0; fd < lim; fd++) 7119 for (fd = 0; fd < lim; fd++)
7014 if (FD_ISSET (fd, &input_wait_mask) 7120 if (FD_ISSET (fd, &input_wait_mask) || FD_ISSET (fd, &write_mask))
7015 && !FD_ISSET (fd, &non_keyboard_wait_mask) 7121 max_input_desc = fd;
7016 && !FD_ISSET (fd, &gpm_wait_mask)) 7122#endif
7017 max_keyboard_desc = fd;
7018#endif /* subprocesses */
7019} 7123}
7020 7124
7021/* Setup coding systems of PROCESS. */ 7125/* Setup coding systems of PROCESS. */
@@ -7272,7 +7376,9 @@ init_process (void)
7272 FD_ZERO (&input_wait_mask); 7376 FD_ZERO (&input_wait_mask);
7273 FD_ZERO (&non_keyboard_wait_mask); 7377 FD_ZERO (&non_keyboard_wait_mask);
7274 FD_ZERO (&non_process_wait_mask); 7378 FD_ZERO (&non_process_wait_mask);
7379 FD_ZERO (&write_mask);
7275 max_process_desc = 0; 7380 max_process_desc = 0;
7381 memset (fd_callback_info, 0, sizeof (fd_callback_info));
7276 7382
7277#ifdef NON_BLOCKING_CONNECT 7383#ifdef NON_BLOCKING_CONNECT
7278 FD_ZERO (&connect_wait_mask); 7384 FD_ZERO (&connect_wait_mask);
diff --git a/src/process.h b/src/process.h
index 35b01aba6a4..0350e95310d 100644
--- a/src/process.h
+++ b/src/process.h
@@ -24,6 +24,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24#include <unistd.h> 24#include <unistd.h>
25#endif 25#endif
26 26
27#ifdef HAVE_GNUTLS
28#include "gnutls.h"
29#endif
30
27/* This structure records information about a subprocess 31/* This structure records information about a subprocess
28 or network connection. 32 or network connection.
29 33
@@ -76,6 +80,10 @@ struct Lisp_Process
76 /* Working buffer for encoding. */ 80 /* Working buffer for encoding. */
77 Lisp_Object encoding_buf; 81 Lisp_Object encoding_buf;
78 82
83#ifdef HAVE_GNUTLS
84 Lisp_Object gnutls_cred_type;
85#endif
86
79 /* After this point, there are no Lisp_Objects any more. */ 87 /* After this point, there are no Lisp_Objects any more. */
80 /* alloc.c assumes that `pid' is the first such non-Lisp slot. */ 88 /* alloc.c assumes that `pid' is the first such non-Lisp slot. */
81 89
@@ -121,6 +129,15 @@ struct Lisp_Process
121 needs to be synced to `status'. */ 129 needs to be synced to `status'. */
122 unsigned int raw_status_new : 1; 130 unsigned int raw_status_new : 1;
123 int raw_status; 131 int raw_status;
132
133#ifdef HAVE_GNUTLS
134 gnutls_initstage_t gnutls_initstage;
135 gnutls_session_t gnutls_state;
136 gnutls_certificate_client_credentials gnutls_x509_cred;
137 gnutls_anon_client_credentials_t gnutls_anon_cred;
138 int gnutls_log_level;
139 int gnutls_p;
140#endif
124}; 141};
125 142
126/* Every field in the preceding structure except for the first two 143/* Every field in the preceding structure except for the first two
@@ -177,5 +194,12 @@ extern void hold_keyboard_input (void);
177extern void unhold_keyboard_input (void); 194extern void unhold_keyboard_input (void);
178extern int kbd_on_hold_p (void); 195extern int kbd_on_hold_p (void);
179 196
197typedef void (*fd_callback)(int fd, void *data, int for_read);
198
199extern void add_read_fd (int fd, fd_callback func, void *data);
200extern void delete_read_fd (int fd);
201extern void add_write_fd (int fd, fd_callback func, void *data);
202extern void delete_write_fd (int fd);
203
180/* arch-tag: dffedfc4-d7bc-4b58-a26f-c16155449c72 204/* arch-tag: dffedfc4-d7bc-4b58-a26f-c16155449c72
181 (do not change this comment) */ 205 (do not change this comment) */
diff --git a/src/region-cache.c b/src/region-cache.c
index 45eb723c885..9037b5df4b4 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -62,7 +62,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62 revalidate_region_cache to see how this helps. */ 62 revalidate_region_cache to see how this helps. */
63 63
64struct boundary { 64struct boundary {
65 int pos; 65 EMACS_INT pos;
66 int value; 66 int value;
67}; 67};
68 68
@@ -72,16 +72,16 @@ struct region_cache {
72 struct boundary *boundaries; 72 struct boundary *boundaries;
73 73
74 /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */ 74 /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */
75 int gap_start, gap_len; 75 EMACS_INT gap_start, gap_len;
76 76
77 /* The number of elements allocated to boundaries, not including the 77 /* The number of elements allocated to boundaries, not including the
78 gap. */ 78 gap. */
79 int cache_len; 79 EMACS_INT cache_len;
80 80
81 /* The areas that haven't changed since the last time we cleaned out 81 /* The areas that haven't changed since the last time we cleaned out
82 invalid entries from the cache. These overlap when the buffer is 82 invalid entries from the cache. These overlap when the buffer is
83 entirely unchanged. */ 83 entirely unchanged. */
84 int beg_unchanged, end_unchanged; 84 EMACS_INT beg_unchanged, end_unchanged;
85 85
86 /* The first and last positions in the buffer. Because boundaries 86 /* The first and last positions in the buffer. Because boundaries
87 store their positions relative to the start (BEG) and end (Z) of 87 store their positions relative to the start (BEG) and end (Z) of
@@ -91,7 +91,7 @@ struct region_cache {
91 91
92 Yes, buffer_beg is always 1. It's there for symmetry with 92 Yes, buffer_beg is always 1. It's there for symmetry with
93 buffer_end and the BEG and BUF_BEG macros. */ 93 buffer_end and the BEG and BUF_BEG macros. */
94 int buffer_beg, buffer_end; 94 EMACS_INT buffer_beg, buffer_end;
95}; 95};
96 96
97/* Return the position of boundary i in cache c. */ 97/* Return the position of boundary i in cache c. */
@@ -172,17 +172,17 @@ free_region_cache (struct region_cache *c)
172 This operation should be logarithmic in the number of cache 172 This operation should be logarithmic in the number of cache
173 entries. It would be nice if it took advantage of locality of 173 entries. It would be nice if it took advantage of locality of
174 reference, too, by searching entries near the last entry found. */ 174 reference, too, by searching entries near the last entry found. */
175static int 175static EMACS_INT
176find_cache_boundary (struct region_cache *c, int pos) 176find_cache_boundary (struct region_cache *c, EMACS_INT pos)
177{ 177{
178 int low = 0, high = c->cache_len; 178 EMACS_INT low = 0, high = c->cache_len;
179 179
180 while (low + 1 < high) 180 while (low + 1 < high)
181 { 181 {
182 /* mid is always a valid index, because low < high and ">> 1" 182 /* mid is always a valid index, because low < high and ">> 1"
183 rounds down. */ 183 rounds down. */
184 int mid = (low + high) >> 1; 184 EMACS_INT mid = (low + high) >> 1;
185 int boundary = BOUNDARY_POS (c, mid); 185 EMACS_INT boundary = BOUNDARY_POS (c, mid);
186 186
187 if (pos < boundary) 187 if (pos < boundary)
188 high = mid; 188 high = mid;
@@ -207,13 +207,13 @@ find_cache_boundary (struct region_cache *c, int pos)
207/* Move the gap of cache C to index POS, and make sure it has space 207/* Move the gap of cache C to index POS, and make sure it has space
208 for at least MIN_SIZE boundaries. */ 208 for at least MIN_SIZE boundaries. */
209static void 209static void
210move_cache_gap (struct region_cache *c, int pos, int min_size) 210move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size)
211{ 211{
212 /* Copy these out of the cache and into registers. */ 212 /* Copy these out of the cache and into registers. */
213 int gap_start = c->gap_start; 213 EMACS_INT gap_start = c->gap_start;
214 int gap_len = c->gap_len; 214 EMACS_INT gap_len = c->gap_len;
215 int buffer_beg = c->buffer_beg; 215 EMACS_INT buffer_beg = c->buffer_beg;
216 int buffer_end = c->buffer_end; 216 EMACS_INT buffer_end = c->buffer_end;
217 217
218 if (pos < 0 218 if (pos < 0
219 || pos > c->cache_len) 219 || pos > c->cache_len)
@@ -245,7 +245,7 @@ move_cache_gap (struct region_cache *c, int pos, int min_size)
245 when the portion after the gap is smallest. */ 245 when the portion after the gap is smallest. */
246 if (gap_len < min_size) 246 if (gap_len < min_size)
247 { 247 {
248 int i; 248 EMACS_INT i;
249 249
250 /* Always make at least NEW_CACHE_GAP elements, as long as we're 250 /* Always make at least NEW_CACHE_GAP elements, as long as we're
251 expanding anyway. */ 251 expanding anyway. */
@@ -292,7 +292,8 @@ move_cache_gap (struct region_cache *c, int pos, int min_size)
292/* Insert a new boundary in cache C; it will have cache index INDEX, 292/* Insert a new boundary in cache C; it will have cache index INDEX,
293 and have the specified POS and VALUE. */ 293 and have the specified POS and VALUE. */
294static void 294static void
295insert_cache_boundary (struct region_cache *c, int index, int pos, int value) 295insert_cache_boundary (struct region_cache *c, EMACS_INT index, EMACS_INT pos,
296 int value)
296{ 297{
297 /* index must be a valid cache index. */ 298 /* index must be a valid cache index. */
298 if (index < 0 || index > c->cache_len) 299 if (index < 0 || index > c->cache_len)
@@ -328,9 +329,10 @@ insert_cache_boundary (struct region_cache *c, int index, int pos, int value)
328/* Delete the i'th entry from cache C if START <= i < END. */ 329/* Delete the i'th entry from cache C if START <= i < END. */
329 330
330static void 331static void
331delete_cache_boundaries (struct region_cache *c, int start, int end) 332delete_cache_boundaries (struct region_cache *c,
333 EMACS_INT start, EMACS_INT end)
332{ 334{
333 int len = end - start; 335 EMACS_INT len = end - start;
334 336
335 /* Gotta be in range. */ 337 /* Gotta be in range. */
336 if (start < 0 338 if (start < 0
@@ -380,7 +382,8 @@ delete_cache_boundaries (struct region_cache *c, int start, int end)
380 382
381/* Set the value in cache C for the region START..END to VALUE. */ 383/* Set the value in cache C for the region START..END to VALUE. */
382static void 384static void
383set_cache_region (struct region_cache *c, int start, int end, int value) 385set_cache_region (struct region_cache *c,
386 EMACS_INT start, EMACS_INT end, int value)
384{ 387{
385 if (start > end) 388 if (start > end)
386 abort (); 389 abort ();
@@ -403,8 +406,8 @@ set_cache_region (struct region_cache *c, int start, int end, int value)
403 index of the earliest boundary after the last character in 406 index of the earliest boundary after the last character in
404 start..end. (This tortured terminology is intended to answer 407 start..end. (This tortured terminology is intended to answer
405 all the "< or <=?" sort of questions.) */ 408 all the "< or <=?" sort of questions.) */
406 int start_ix = find_cache_boundary (c, start); 409 EMACS_INT start_ix = find_cache_boundary (c, start);
407 int end_ix = find_cache_boundary (c, end - 1) + 1; 410 EMACS_INT end_ix = find_cache_boundary (c, end - 1) + 1;
408 411
409 /* We must remember the value established by the last boundary 412 /* We must remember the value established by the last boundary
410 before end; if that boundary's domain stretches beyond end, 413 before end; if that boundary's domain stretches beyond end,
@@ -481,7 +484,8 @@ set_cache_region (struct region_cache *c, int start, int end, int value)
481 buffer positions in the presence of insertions and deletions; the 484 buffer positions in the presence of insertions and deletions; the
482 args to pass are the same before and after such an operation.) */ 485 args to pass are the same before and after such an operation.) */
483void 486void
484invalidate_region_cache (struct buffer *buf, struct region_cache *c, int head, int tail) 487invalidate_region_cache (struct buffer *buf, struct region_cache *c,
488 EMACS_INT head, EMACS_INT tail)
485{ 489{
486 /* Let chead = c->beg_unchanged, and 490 /* Let chead = c->beg_unchanged, and
487 ctail = c->end_unchanged. 491 ctail = c->end_unchanged.
@@ -619,7 +623,7 @@ revalidate_region_cache (struct buffer *buf, struct region_cache *c)
619 corresponds to the modified region of the buffer. */ 623 corresponds to the modified region of the buffer. */
620 else 624 else
621 { 625 {
622 int modified_ix; 626 EMACS_INT modified_ix;
623 627
624 /* These positions are correct, relative to both the cache basis 628 /* These positions are correct, relative to both the cache basis
625 and the buffer basis. */ 629 and the buffer basis. */
@@ -687,7 +691,8 @@ revalidate_region_cache (struct buffer *buf, struct region_cache *c)
687 buffer positions) is "known," for the purposes of CACHE (e.g. "has 691 buffer positions) is "known," for the purposes of CACHE (e.g. "has
688 no newlines", in the case of the line cache). */ 692 no newlines", in the case of the line cache). */
689void 693void
690know_region_cache (struct buffer *buf, struct region_cache *c, int start, int end) 694know_region_cache (struct buffer *buf, struct region_cache *c,
695 EMACS_INT start, EMACS_INT end)
691{ 696{
692 revalidate_region_cache (buf, c); 697 revalidate_region_cache (buf, c);
693 698
@@ -701,14 +706,15 @@ know_region_cache (struct buffer *buf, struct region_cache *c, int start, int en
701 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest 706 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
702 position after POS where the knownness changes. */ 707 position after POS where the knownness changes. */
703int 708int
704region_cache_forward (struct buffer *buf, struct region_cache *c, int pos, int *next) 709region_cache_forward (struct buffer *buf, struct region_cache *c,
710 EMACS_INT pos, EMACS_INT *next)
705{ 711{
706 revalidate_region_cache (buf, c); 712 revalidate_region_cache (buf, c);
707 713
708 { 714 {
709 int i = find_cache_boundary (c, pos); 715 EMACS_INT i = find_cache_boundary (c, pos);
710 int i_value = BOUNDARY_VALUE (c, i); 716 int i_value = BOUNDARY_VALUE (c, i);
711 int j; 717 EMACS_INT j;
712 718
713 /* Beyond the end of the buffer is unknown, by definition. */ 719 /* Beyond the end of the buffer is unknown, by definition. */
714 if (pos >= BUF_Z (buf)) 720 if (pos >= BUF_Z (buf))
@@ -736,7 +742,8 @@ region_cache_forward (struct buffer *buf, struct region_cache *c, int pos, int *
736/* Return true if the text immediately before POS in BUF is known, for 742/* Return true if the text immediately before POS in BUF is known, for
737 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest 743 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
738 position before POS where the knownness changes. */ 744 position before POS where the knownness changes. */
739int region_cache_backward (struct buffer *buf, struct region_cache *c, int pos, int *next) 745int region_cache_backward (struct buffer *buf, struct region_cache *c,
746 EMACS_INT pos, EMACS_INT *next)
740{ 747{
741 revalidate_region_cache (buf, c); 748 revalidate_region_cache (buf, c);
742 749
@@ -749,9 +756,9 @@ int region_cache_backward (struct buffer *buf, struct region_cache *c, int pos,
749 } 756 }
750 757
751 { 758 {
752 int i = find_cache_boundary (c, pos - 1); 759 EMACS_INT i = find_cache_boundary (c, pos - 1);
753 int i_value = BOUNDARY_VALUE (c, i); 760 int i_value = BOUNDARY_VALUE (c, i);
754 int j; 761 EMACS_INT j;
755 762
756 if (next) 763 if (next)
757 { 764 {
@@ -777,17 +784,17 @@ void
777pp_cache (struct region_cache *c) 784pp_cache (struct region_cache *c)
778{ 785{
779 int i; 786 int i;
780 int beg_u = c->buffer_beg + c->beg_unchanged; 787 EMACS_INT beg_u = c->buffer_beg + c->beg_unchanged;
781 int end_u = c->buffer_end - c->end_unchanged; 788 EMACS_INT end_u = c->buffer_end - c->end_unchanged;
782 789
783 fprintf (stderr, 790 fprintf (stderr,
784 "basis: %d..%d modified: %d..%d\n", 791 "basis: %ld..%ld modified: %ld..%ld\n",
785 c->buffer_beg, c->buffer_end, 792 (long)c->buffer_beg, (long)c->buffer_end,
786 beg_u, end_u); 793 (long)beg_u, (long)end_u);
787 794
788 for (i = 0; i < c->cache_len; i++) 795 for (i = 0; i < c->cache_len; i++)
789 { 796 {
790 int pos = BOUNDARY_POS (c, i); 797 EMACS_INT pos = BOUNDARY_POS (c, i);
791 798
792 putc (((pos < beg_u) ? 'v' 799 putc (((pos < beg_u) ? 'v'
793 : (pos == beg_u) ? '-' 800 : (pos == beg_u) ? '-'
@@ -797,7 +804,7 @@ pp_cache (struct region_cache *c)
797 : (pos == end_u) ? '-' 804 : (pos == end_u) ? '-'
798 : ' '), 805 : ' '),
799 stderr); 806 stderr);
800 fprintf (stderr, "%d : %d\n", pos, BOUNDARY_VALUE (c, i)); 807 fprintf (stderr, "%ld : %d\n", (long)pos, BOUNDARY_VALUE (c, i));
801 } 808 }
802} 809}
803 810
diff --git a/src/region-cache.h b/src/region-cache.h
index e2972f2ea0a..e99eac90c85 100644
--- a/src/region-cache.h
+++ b/src/region-cache.h
@@ -71,7 +71,7 @@ void free_region_cache (struct region_cache *);
71 no newlines", in the case of the line cache). */ 71 no newlines", in the case of the line cache). */
72extern void know_region_cache (struct buffer *BUF, 72extern void know_region_cache (struct buffer *BUF,
73 struct region_cache *CACHE, 73 struct region_cache *CACHE,
74 int START, int END); 74 EMACS_INT START, EMACS_INT END);
75 75
76/* Indicate that a section of BUF has changed, to invalidate CACHE. 76/* Indicate that a section of BUF has changed, to invalidate CACHE.
77 HEAD is the number of chars unchanged at the beginning of the buffer. 77 HEAD is the number of chars unchanged at the beginning of the buffer.
@@ -83,7 +83,7 @@ extern void know_region_cache (struct buffer *BUF,
83 args to pass are the same before and after such an operation.) */ 83 args to pass are the same before and after such an operation.) */
84extern void invalidate_region_cache (struct buffer *BUF, 84extern void invalidate_region_cache (struct buffer *BUF,
85 struct region_cache *CACHE, 85 struct region_cache *CACHE,
86 int HEAD, int TAIL); 86 EMACS_INT HEAD, EMACS_INT TAIL);
87 87
88/* The scanning functions. 88/* The scanning functions.
89 89
@@ -99,16 +99,16 @@ extern void invalidate_region_cache (struct buffer *BUF,
99 position after POS where the knownness changes. */ 99 position after POS where the knownness changes. */
100extern int region_cache_forward (struct buffer *BUF, 100extern int region_cache_forward (struct buffer *BUF,
101 struct region_cache *CACHE, 101 struct region_cache *CACHE,
102 int POS, 102 EMACS_INT POS,
103 int *NEXT); 103 EMACS_INT *NEXT);
104 104
105/* Return true if the text immediately before POS in BUF is known, for 105/* Return true if the text immediately before POS in BUF is known, for
106 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest 106 the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
107 position before POS where the knownness changes. */ 107 position before POS where the knownness changes. */
108extern int region_cache_backward (struct buffer *BUF, 108extern int region_cache_backward (struct buffer *BUF,
109 struct region_cache *CACHE, 109 struct region_cache *CACHE,
110 int POS, 110 EMACS_INT POS,
111 int *NEXT); 111 EMACS_INT *NEXT);
112 112
113/* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435 113/* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435
114 (do not change this comment) */ 114 (do not change this comment) */
diff --git a/src/s/aix4-2.h b/src/s/aix4-2.h
index 0a3d48db639..29702028649 100644
--- a/src/s/aix4-2.h
+++ b/src/s/aix4-2.h
@@ -37,10 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptc"); 37#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptc");
38#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ttyname (fd)); 38#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ttyname (fd));
39 39
40/* Define HAVE_TERMIO if the system provides sysV-style ioctls
41 for terminal control. */
42#define HAVE_TERMIOS
43
44/* Define HAVE_PTYS if the system supports pty devices. */ 40/* Define HAVE_PTYS if the system supports pty devices. */
45#define HAVE_PTYS 41#define HAVE_PTYS
46 42
diff --git a/src/s/bsd-common.h b/src/s/bsd-common.h
index bf78f4ec347..b17ca7a012f 100644
--- a/src/s/bsd-common.h
+++ b/src/s/bsd-common.h
@@ -42,7 +42,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#undef KERNEL_FILE 42#undef KERNEL_FILE
43#undef LDAV_SYMBOL 43#undef LDAV_SYMBOL
44 44
45#define HAVE_TERMIOS
46#define NO_TERMIO 45#define NO_TERMIO
47 46
48/* If the system's imake configuration file defines `NeedWidePrototypes' 47/* If the system's imake configuration file defines `NeedWidePrototypes'
diff --git a/src/s/cygwin.h b/src/s/cygwin.h
index 1b78ada53bd..4d58542e660 100644
--- a/src/s/cygwin.h
+++ b/src/s/cygwin.h
@@ -45,16 +45,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
45 through a pipe. */ 45 through a pipe. */
46#undef INTERRUPT_INPUT 46#undef INTERRUPT_INPUT
47 47
48/* Define HAVE_TERMIOS if the system provides POSIX-style
49 functions and macros for terminal control.
50
51 Define HAVE_TERMIO if the system provides sysV-style ioctls
52 for terminal control.
53
54 Do not define both. HAVE_TERMIOS is preferred, if it is
55 supported on your system. */
56#define HAVE_TERMIOS
57
58/* Define HAVE_PTYS if the system supports pty devices. */ 48/* Define HAVE_PTYS if the system supports pty devices. */
59#define HAVE_PTYS 49#define HAVE_PTYS
60#define PTY_ITERATION for (i = 0; i < 1; i++) /* ick */ 50#define PTY_ITERATION for (i = 0; i < 1; i++) /* ick */
diff --git a/src/s/darwin.h b/src/s/darwin.h
index 146bfd693a2..73e19602275 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -63,15 +63,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63 if system supports pty's. 'a' means it is /dev/ptya0 */ 63 if system supports pty's. 'a' means it is /dev/ptya0 */
64#define FIRST_PTY_LETTER 'p' 64#define FIRST_PTY_LETTER 'p'
65 65
66/* Define HAVE_TERMIOS if the system provides POSIX-style
67 functions and macros for terminal control.
68
69 Define HAVE_TERMIO if the system provides sysV-style ioctls
70 for terminal control.
71
72 Do not define both. HAVE_TERMIOS is preferred, if it is supported
73 on your system. */
74#define HAVE_TERMIOS
75#define NO_TERMIO 66#define NO_TERMIO
76 67
77/* Define HAVE_PTYS if the system supports pty devices. 68/* Define HAVE_PTYS if the system supports pty devices.
diff --git a/src/s/gnu-linux.h b/src/s/gnu-linux.h
index cf3b3079726..9327423b42f 100644
--- a/src/s/gnu-linux.h
+++ b/src/s/gnu-linux.h
@@ -80,10 +80,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
80 80
81#endif /* not HAVE_GRANTPT */ 81#endif /* not HAVE_GRANTPT */
82 82
83/* Define HAVE_TERMIOS if the system provides POSIX-style
84 functions and macros for terminal control. */
85#define HAVE_TERMIOS
86
87/* Define HAVE_PTYS if the system supports pty devices. */ 83/* Define HAVE_PTYS if the system supports pty devices. */
88#define HAVE_PTYS 84#define HAVE_PTYS
89 85
diff --git a/src/s/hpux10-20.h b/src/s/hpux10-20.h
index d34ff16104b..0932e6f7112 100644
--- a/src/s/hpux10-20.h
+++ b/src/s/hpux10-20.h
@@ -35,11 +35,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35 if system supports pty's. 'p' means it is /dev/ptym/ptyp0 */ 35 if system supports pty's. 'p' means it is /dev/ptym/ptyp0 */
36#define FIRST_PTY_LETTER 'p' 36#define FIRST_PTY_LETTER 'p'
37 37
38#define HAVE_TERMIOS
39#define NO_TERMIO 38#define NO_TERMIO
40 39
41#define ORDINARY_LINK
42
43/* Define HAVE_PTYS if the system supports pty devices. */ 40/* Define HAVE_PTYS if the system supports pty devices. */
44#define HAVE_PTYS 41#define HAVE_PTYS
45 42
@@ -78,9 +75,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
78 HP-UX 10.20, and that it works for HP-UX 0 as well. */ 75 HP-UX 10.20, and that it works for HP-UX 0 as well. */
79#define NO_EDITRES 76#define NO_EDITRES
80 77
81/* Tested in getloadavg.c. */
82#define HAVE_PSTAT_GETDYNAMIC
83
84/* Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines 78/* Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines
85 has a broken `rint' in some library versions including math library 79 has a broken `rint' in some library versions including math library
86 version number A.09.05. 80 version number A.09.05.
diff --git a/src/s/template.h b/src/s/template.h
index dd1e56f8553..eb7ca85c5e5 100644
--- a/src/s/template.h
+++ b/src/s/template.h
@@ -63,18 +63,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63 if system supports pty's. 'a' means it is /dev/ptya0. */ 63 if system supports pty's. 'a' means it is /dev/ptya0. */
64#define FIRST_PTY_LETTER 'a' 64#define FIRST_PTY_LETTER 'a'
65 65
66/* Define HAVE_TERMIOS if the system provides POSIX-style
67 functions and macros for terminal control.
68
69 Define HAVE_TERMIO if the system provides sysV-style ioctls
70 for terminal control.
71
72 Do not define both. HAVE_TERMIOS is preferred, if it is
73 supported on your system. */
74
75#define HAVE_TERMIOS
76/* #define HAVE_TERMIO */
77
78/* Define HAVE_PTYS if the system supports pty devices. */ 66/* Define HAVE_PTYS if the system supports pty devices. */
79#define HAVE_PTYS 67#define HAVE_PTYS
80 68
diff --git a/src/s/usg5-4-common.h b/src/s/usg5-4-common.h
index 7ff5c6f7be3..4dcb8e50200 100644
--- a/src/s/usg5-4-common.h
+++ b/src/s/usg5-4-common.h
@@ -31,10 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 It sets the Lisp variable system-type. */ 31 It sets the Lisp variable system-type. */
32#define SYSTEM_TYPE "usg-unix-v" 32#define SYSTEM_TYPE "usg-unix-v"
33 33
34/* Define HAVE_TERMIO if the system provides sysV-style ioctls
35 for terminal control. */
36#define HAVE_TERMIO
37
38/* The file containing the kernel's symbol table is called /unix. */ 34/* The file containing the kernel's symbol table is called /unix. */
39#define KERNEL_FILE "/unix" 35#define KERNEL_FILE "/unix"
40 36
@@ -78,7 +74,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
78 74
79/* Define HAVE_PTYS if the system supports pty devices. */ 75/* Define HAVE_PTYS if the system supports pty devices. */
80#define HAVE_PTYS 76#define HAVE_PTYS
81#define HAVE_TERMIOS
82 77
83/* It is possible to receive SIGCHLD when there are no children 78/* It is possible to receive SIGCHLD when there are no children
84 waiting, because a previous waitsys(2) cleaned up the carcass of child 79 waiting, because a previous waitsys(2) cleaned up the carcass of child
diff --git a/src/scroll.c b/src/scroll.c
index bdb7f691ee7..ce26acbce64 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -94,7 +94,7 @@ calculate_scrolling (FRAME_PTR frame,
94 int free_at_end) 94 int free_at_end)
95{ 95{
96 register int i, j; 96 register int i, j;
97 int frame_lines = FRAME_LINES (frame); 97 EMACS_INT frame_lines = FRAME_LINES (frame);
98 register struct matrix_elt *p, *p1; 98 register struct matrix_elt *p, *p1;
99 register int cost, cost1; 99 register int cost, cost1;
100 100
@@ -115,7 +115,7 @@ calculate_scrolling (FRAME_PTR frame,
115 /* Discourage long scrolls on fast lines. 115 /* Discourage long scrolls on fast lines.
116 Don't scroll nearly a full frame height unless it saves 116 Don't scroll nearly a full frame height unless it saves
117 at least 1/4 second. */ 117 at least 1/4 second. */
118 int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame)); 118 int extra_cost = (int) (baud_rate / (10 * 4 * FRAME_LINES (frame)));
119 119
120 if (baud_rate <= 0) 120 if (baud_rate <= 0)
121 extra_cost = 1; 121 extra_cost = 1;
@@ -428,7 +428,7 @@ calculate_direct_scrolling (FRAME_PTR frame,
428 int free_at_end) 428 int free_at_end)
429{ 429{
430 register int i, j; 430 register int i, j;
431 int frame_lines = FRAME_LINES (frame); 431 EMACS_INT frame_lines = FRAME_LINES (frame);
432 register struct matrix_elt *p, *p1; 432 register struct matrix_elt *p, *p1;
433 register int cost, cost1, delta; 433 register int cost, cost1, delta;
434 434
@@ -448,7 +448,7 @@ calculate_direct_scrolling (FRAME_PTR frame,
448 /* Discourage long scrolls on fast lines. 448 /* Discourage long scrolls on fast lines.
449 Don't scroll nearly a full frame height unless it saves 449 Don't scroll nearly a full frame height unless it saves
450 at least 1/4 second. */ 450 at least 1/4 second. */
451 int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame)); 451 int extra_cost = (int) (baud_rate / (10 * 4 * FRAME_LINES (frame)));
452 452
453 if (baud_rate <= 0) 453 if (baud_rate <= 0)
454 extra_cost = 1; 454 extra_cost = 1;
@@ -886,9 +886,9 @@ scroll_cost (FRAME_PTR frame, int from, int to, int amount)
886{ 886{
887 /* Compute how many lines, at bottom of frame, 887 /* Compute how many lines, at bottom of frame,
888 will not be involved in actual motion. */ 888 will not be involved in actual motion. */
889 int limit = to; 889 EMACS_INT limit = to;
890 int offset; 890 EMACS_INT offset;
891 int height = FRAME_LINES (frame); 891 EMACS_INT height = FRAME_LINES (frame);
892 892
893 if (amount == 0) 893 if (amount == 0)
894 return 0; 894 return 0;
@@ -921,8 +921,8 @@ scroll_cost (FRAME_PTR frame, int from, int to, int amount)
921static void 921static void
922line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, register int *ov, register int *mf) 922line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, register int *ov, register int *mf)
923{ 923{
924 register int i; 924 register EMACS_INT i;
925 register int frame_lines = FRAME_LINES (frame); 925 register EMACS_INT frame_lines = FRAME_LINES (frame);
926 register int insert_overhead = ov1 * 10; 926 register int insert_overhead = ov1 * 10;
927 register int next_insert_cost = ovn * 10; 927 register int next_insert_cost = ovn * 10;
928 928
diff --git a/src/search.c b/src/search.c
index 0e9840b2e5f..f2957c335a2 100644
--- a/src/search.c
+++ b/src/search.c
@@ -100,15 +100,15 @@ Lisp_Object Vinhibit_changing_match_data;
100 100
101static void set_search_regs (EMACS_INT, EMACS_INT); 101static void set_search_regs (EMACS_INT, EMACS_INT);
102static void save_search_regs (void); 102static void save_search_regs (void);
103static EMACS_INT simple_search (int, unsigned char *, int, int, 103static EMACS_INT simple_search (EMACS_INT, unsigned char *, EMACS_INT,
104 Lisp_Object, EMACS_INT, EMACS_INT, 104 EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT,
105 EMACS_INT, EMACS_INT); 105 EMACS_INT, EMACS_INT);
106static EMACS_INT boyer_moore (int, unsigned char *, int, int, 106static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, EMACS_INT, EMACS_INT,
107 Lisp_Object, Lisp_Object, 107 Lisp_Object, Lisp_Object,
108 EMACS_INT, EMACS_INT, 108 EMACS_INT, EMACS_INT,
109 EMACS_INT, EMACS_INT, int); 109 EMACS_INT, EMACS_INT, int);
110static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT, 110static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT,
111 EMACS_INT, EMACS_INT, int, int, 111 EMACS_INT, EMACS_INT, EMACS_INT, int,
112 Lisp_Object, Lisp_Object, int); 112 Lisp_Object, Lisp_Object, int);
113static void matcher_overflow (void) NO_RETURN; 113static void matcher_overflow (void) NO_RETURN;
114 114
@@ -286,7 +286,7 @@ looking_at_1 (Lisp_Object string, int posix)
286 Lisp_Object val; 286 Lisp_Object val;
287 unsigned char *p1, *p2; 287 unsigned char *p1, *p2;
288 EMACS_INT s1, s2; 288 EMACS_INT s1, s2;
289 register int i; 289 register EMACS_INT i;
290 struct re_pattern_buffer *bufp; 290 struct re_pattern_buffer *bufp;
291 291
292 if (running_asynch_code) 292 if (running_asynch_code)
@@ -396,7 +396,7 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int p
396 pos = 0, pos_byte = 0; 396 pos = 0, pos_byte = 0;
397 else 397 else
398 { 398 {
399 int len = SCHARS (string); 399 EMACS_INT len = SCHARS (string);
400 400
401 CHECK_NUMBER (start); 401 CHECK_NUMBER (start);
402 pos = XINT (start); 402 pos = XINT (start);
@@ -509,7 +509,7 @@ fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string)
509{ 509{
510 int val; 510 int val;
511 struct re_pattern_buffer *bufp; 511 struct re_pattern_buffer *bufp;
512 int len = strlen (string); 512 size_t len = strlen (string);
513 513
514 regexp = string_make_unibyte (regexp); 514 regexp = string_make_unibyte (regexp);
515 re_match_object = Qt; 515 re_match_object = Qt;
@@ -654,8 +654,9 @@ newline_cache_on_off (struct buffer *buf)
654 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 654 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do
655 except when inside redisplay. */ 655 except when inside redisplay. */
656 656
657int 657EMACS_INT
658scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int *shortage, int allow_quit) 658scan_buffer (register int target, EMACS_INT start, EMACS_INT end,
659 EMACS_INT count, int *shortage, int allow_quit)
659{ 660{
660 struct region_cache *newline_cache; 661 struct region_cache *newline_cache;
661 int direction; 662 int direction;
@@ -695,7 +696,7 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int
695 to see where we can avoid some scanning. */ 696 to see where we can avoid some scanning. */
696 if (target == '\n' && newline_cache) 697 if (target == '\n' && newline_cache)
697 { 698 {
698 int next_change; 699 EMACS_INT next_change;
699 immediate_quit = 0; 700 immediate_quit = 0;
700 while (region_cache_forward 701 while (region_cache_forward
701 (current_buffer, newline_cache, start_byte, &next_change)) 702 (current_buffer, newline_cache, start_byte, &next_change))
@@ -767,7 +768,7 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int
767 /* Consult the newline cache, if appropriate. */ 768 /* Consult the newline cache, if appropriate. */
768 if (target == '\n' && newline_cache) 769 if (target == '\n' && newline_cache)
769 { 770 {
770 int next_change; 771 EMACS_INT next_change;
771 immediate_quit = 0; 772 immediate_quit = 0;
772 while (region_cache_backward 773 while (region_cache_backward
773 (current_buffer, newline_cache, start_byte, &next_change)) 774 (current_buffer, newline_cache, start_byte, &next_change))
@@ -846,8 +847,10 @@ scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int
846 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 847 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do
847 except in special cases. */ 848 except in special cases. */
848 849
849int 850EMACS_INT
850scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT limit_byte, register int count, int allow_quit) 851scan_newline (EMACS_INT start, EMACS_INT start_byte,
852 EMACS_INT limit, EMACS_INT limit_byte,
853 register EMACS_INT count, int allow_quit)
851{ 854{
852 int direction = ((count > 0) ? 1 : -1); 855 int direction = ((count > 0) ? 1 : -1);
853 856
@@ -940,8 +943,8 @@ scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT
940 return count * direction; 943 return count * direction;
941} 944}
942 945
943int 946EMACS_INT
944find_next_newline_no_quit (EMACS_INT from, int cnt) 947find_next_newline_no_quit (EMACS_INT from, EMACS_INT cnt)
945{ 948{
946 return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); 949 return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0);
947} 950}
@@ -950,11 +953,11 @@ find_next_newline_no_quit (EMACS_INT from, int cnt)
950 not after, and only search up to TO. This isn't just 953 not after, and only search up to TO. This isn't just
951 find_next_newline (...)-1, because you might hit TO. */ 954 find_next_newline (...)-1, because you might hit TO. */
952 955
953int 956EMACS_INT
954find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt) 957find_before_next_newline (EMACS_INT from, EMACS_INT to, EMACS_INT cnt)
955{ 958{
956 int shortage; 959 int shortage;
957 int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); 960 EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1);
958 961
959 if (shortage == 0) 962 if (shortage == 0)
960 pos--; 963 pos--;
@@ -965,10 +968,11 @@ find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt)
965/* Subroutines of Lisp buffer search functions. */ 968/* Subroutines of Lisp buffer search functions. */
966 969
967static Lisp_Object 970static Lisp_Object
968search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count, int direction, int RE, int posix) 971search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
972 Lisp_Object count, int direction, int RE, int posix)
969{ 973{
970 register int np; 974 register int np;
971 int lim, lim_byte; 975 EMACS_INT lim, lim_byte;
972 int n = direction; 976 int n = direction;
973 977
974 if (!NILP (count)) 978 if (!NILP (count))
@@ -1044,7 +1048,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp
1044static int 1048static int
1045trivial_regexp_p (Lisp_Object regexp) 1049trivial_regexp_p (Lisp_Object regexp)
1046{ 1050{
1047 int len = SBYTES (regexp); 1051 EMACS_INT len = SBYTES (regexp);
1048 unsigned char *s = SDATA (regexp); 1052 unsigned char *s = SDATA (regexp);
1049 while (--len >= 0) 1053 while (--len >= 0)
1050 { 1054 {
@@ -1109,11 +1113,11 @@ static struct re_registers search_regs_1;
1109 1113
1110static EMACS_INT 1114static EMACS_INT
1111search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte, 1115search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1112 EMACS_INT lim, EMACS_INT lim_byte, int n, 1116 EMACS_INT lim, EMACS_INT lim_byte, EMACS_INT n,
1113 int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix) 1117 int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
1114{ 1118{
1115 int len = SCHARS (string); 1119 EMACS_INT len = SCHARS (string);
1116 int len_byte = SBYTES (string); 1120 EMACS_INT len_byte = SBYTES (string);
1117 register int i; 1121 register int i;
1118 1122
1119 if (running_asynch_code) 1123 if (running_asynch_code)
@@ -1130,7 +1134,7 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1130 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp))) 1134 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
1131 { 1135 {
1132 unsigned char *p1, *p2; 1136 unsigned char *p1, *p2;
1133 int s1, s2; 1137 EMACS_INT s1, s2;
1134 struct re_pattern_buffer *bufp; 1138 struct re_pattern_buffer *bufp;
1135 1139
1136 bufp = compile_pattern (string, 1140 bufp = compile_pattern (string,
@@ -1166,7 +1170,7 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1166 1170
1167 while (n < 0) 1171 while (n < 0)
1168 { 1172 {
1169 int val; 1173 EMACS_INT val;
1170 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, 1174 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
1171 pos_byte - BEGV_BYTE, lim_byte - pos_byte, 1175 pos_byte - BEGV_BYTE, lim_byte - pos_byte,
1172 (NILP (Vinhibit_changing_match_data) 1176 (NILP (Vinhibit_changing_match_data)
@@ -1210,7 +1214,7 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1210 } 1214 }
1211 while (n > 0) 1215 while (n > 0)
1212 { 1216 {
1213 int val; 1217 EMACS_INT val;
1214 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, 1218 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
1215 pos_byte - BEGV_BYTE, lim_byte - pos_byte, 1219 pos_byte - BEGV_BYTE, lim_byte - pos_byte,
1216 (NILP (Vinhibit_changing_match_data) 1220 (NILP (Vinhibit_changing_match_data)
@@ -1255,8 +1259,8 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1255 else /* non-RE case */ 1259 else /* non-RE case */
1256 { 1260 {
1257 unsigned char *raw_pattern, *pat; 1261 unsigned char *raw_pattern, *pat;
1258 int raw_pattern_size; 1262 EMACS_INT raw_pattern_size;
1259 int raw_pattern_size_byte; 1263 EMACS_INT raw_pattern_size_byte;
1260 unsigned char *patbuf; 1264 unsigned char *patbuf;
1261 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 1265 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
1262 unsigned char *base_pat; 1266 unsigned char *base_pat;
@@ -1450,13 +1454,16 @@ search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
1450 boyer_moore cannot work. */ 1454 boyer_moore cannot work. */
1451 1455
1452static EMACS_INT 1456static EMACS_INT
1453simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT lim, EMACS_INT lim_byte) 1457simple_search (EMACS_INT n, unsigned char *pat,
1458 EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt,
1459 EMACS_INT pos, EMACS_INT pos_byte,
1460 EMACS_INT lim, EMACS_INT lim_byte)
1454{ 1461{
1455 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 1462 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
1456 int forward = n > 0; 1463 int forward = n > 0;
1457 /* Number of buffer bytes matched. Note that this may be different 1464 /* Number of buffer bytes matched. Note that this may be different
1458 from len_byte in a multibyte buffer. */ 1465 from len_byte in a multibyte buffer. */
1459 int match_byte; 1466 EMACS_INT match_byte;
1460 1467
1461 if (lim > pos && multibyte) 1468 if (lim > pos && multibyte)
1462 while (n > 0) 1469 while (n > 0)
@@ -1466,7 +1473,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1466 /* Try matching at position POS. */ 1473 /* Try matching at position POS. */
1467 EMACS_INT this_pos = pos; 1474 EMACS_INT this_pos = pos;
1468 EMACS_INT this_pos_byte = pos_byte; 1475 EMACS_INT this_pos_byte = pos_byte;
1469 int this_len = len; 1476 EMACS_INT this_len = len;
1470 unsigned char *p = pat; 1477 unsigned char *p = pat;
1471 if (pos + len > lim || pos_byte + len_byte > lim_byte) 1478 if (pos + len > lim || pos_byte + len_byte > lim_byte)
1472 goto stop; 1479 goto stop;
@@ -1511,7 +1518,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1511 { 1518 {
1512 /* Try matching at position POS. */ 1519 /* Try matching at position POS. */
1513 EMACS_INT this_pos = pos; 1520 EMACS_INT this_pos = pos;
1514 int this_len = len; 1521 EMACS_INT this_len = len;
1515 unsigned char *p = pat; 1522 unsigned char *p = pat;
1516 1523
1517 if (pos + len > lim) 1524 if (pos + len > lim)
@@ -1551,7 +1558,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1551 /* Try matching at position POS. */ 1558 /* Try matching at position POS. */
1552 EMACS_INT this_pos = pos; 1559 EMACS_INT this_pos = pos;
1553 EMACS_INT this_pos_byte = pos_byte; 1560 EMACS_INT this_pos_byte = pos_byte;
1554 int this_len = len; 1561 EMACS_INT this_len = len;
1555 const unsigned char *p = pat + len_byte; 1562 const unsigned char *p = pat + len_byte;
1556 1563
1557 if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte) 1564 if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
@@ -1594,7 +1601,7 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1594 { 1601 {
1595 /* Try matching at position POS. */ 1602 /* Try matching at position POS. */
1596 EMACS_INT this_pos = pos - len; 1603 EMACS_INT this_pos = pos - len;
1597 int this_len = len; 1604 EMACS_INT this_len = len;
1598 unsigned char *p = pat; 1605 unsigned char *p = pat;
1599 1606
1600 if (this_pos < lim) 1607 if (this_pos < lim)
@@ -1657,18 +1664,20 @@ simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt
1657 If that criterion is not satisfied, do not call this function. */ 1664 If that criterion is not satisfied, do not call this function. */
1658 1665
1659static EMACS_INT 1666static EMACS_INT
1660boyer_moore (int n, unsigned char *base_pat, int len, int len_byte, 1667boyer_moore (EMACS_INT n, unsigned char *base_pat,
1668 EMACS_INT len, EMACS_INT len_byte,
1661 Lisp_Object trt, Lisp_Object inverse_trt, 1669 Lisp_Object trt, Lisp_Object inverse_trt,
1662 EMACS_INT pos, EMACS_INT pos_byte, 1670 EMACS_INT pos, EMACS_INT pos_byte,
1663 EMACS_INT lim, EMACS_INT lim_byte, int char_base) 1671 EMACS_INT lim, EMACS_INT lim_byte, int char_base)
1664{ 1672{
1665 int direction = ((n > 0) ? 1 : -1); 1673 int direction = ((n > 0) ? 1 : -1);
1666 register int dirlen; 1674 register EMACS_INT dirlen;
1667 EMACS_INT limit; 1675 EMACS_INT limit;
1668 int stride_for_teases = 0; 1676 int stride_for_teases = 0;
1669 int BM_tab[0400]; 1677 int BM_tab[0400];
1670 register unsigned char *cursor, *p_limit; 1678 register unsigned char *cursor, *p_limit;
1671 register int i, j; 1679 register EMACS_INT i;
1680 register int j;
1672 unsigned char *pat, *pat_end; 1681 unsigned char *pat, *pat_end;
1673 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 1682 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
1674 1683
@@ -2098,10 +2107,11 @@ static Lisp_Object
2098wordify (Lisp_Object string, int lax) 2107wordify (Lisp_Object string, int lax)
2099{ 2108{
2100 register unsigned char *p, *o; 2109 register unsigned char *p, *o;
2101 register int i, i_byte, len, punct_count = 0, word_count = 0; 2110 register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0;
2102 Lisp_Object val; 2111 Lisp_Object val;
2103 int prev_c = 0; 2112 int prev_c = 0;
2104 int adjust, whitespace_at_end; 2113 EMACS_INT adjust;
2114 int whitespace_at_end;
2105 2115
2106 CHECK_STRING (string); 2116 CHECK_STRING (string);
2107 p = SDATA (string); 2117 p = SDATA (string);
@@ -2151,7 +2161,7 @@ wordify (Lisp_Object string, int lax)
2151 for (i = 0, i_byte = 0; i < len; ) 2161 for (i = 0, i_byte = 0; i < len; )
2152 { 2162 {
2153 int c; 2163 int c;
2154 int i_byte_orig = i_byte; 2164 EMACS_INT i_byte_orig = i_byte;
2155 2165
2156 FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte); 2166 FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte);
2157 2167
@@ -2392,7 +2402,7 @@ since only regular expressions have distinguished subexpressions. */)
2392 (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) 2402 (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp)
2393{ 2403{
2394 enum { nochange, all_caps, cap_initial } case_action; 2404 enum { nochange, all_caps, cap_initial } case_action;
2395 register int pos, pos_byte; 2405 register EMACS_INT pos, pos_byte;
2396 int some_multiletter_word; 2406 int some_multiletter_word;
2397 int some_lowercase; 2407 int some_lowercase;
2398 int some_uppercase; 2408 int some_uppercase;
@@ -2540,8 +2550,8 @@ since only regular expressions have distinguished subexpressions. */)
2540 2550
2541 for (pos_byte = 0, pos = 0; pos_byte < length;) 2551 for (pos_byte = 0, pos = 0; pos_byte < length;)
2542 { 2552 {
2543 int substart = -1; 2553 EMACS_INT substart = -1;
2544 int subend = 0; 2554 EMACS_INT subend = 0;
2545 int delbackslash = 0; 2555 int delbackslash = 0;
2546 2556
2547 FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); 2557 FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
@@ -2634,9 +2644,9 @@ since only regular expressions have distinguished subexpressions. */)
2634 perform substitution on the replacement string. */ 2644 perform substitution on the replacement string. */
2635 if (NILP (literal)) 2645 if (NILP (literal))
2636 { 2646 {
2637 int length = SBYTES (newtext); 2647 EMACS_INT length = SBYTES (newtext);
2638 unsigned char *substed; 2648 unsigned char *substed;
2639 int substed_alloc_size, substed_len; 2649 EMACS_INT substed_alloc_size, substed_len;
2640 int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); 2650 int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters);
2641 int str_multibyte = STRING_MULTIBYTE (newtext); 2651 int str_multibyte = STRING_MULTIBYTE (newtext);
2642 Lisp_Object rev_tbl; 2652 Lisp_Object rev_tbl;
@@ -2656,7 +2666,7 @@ since only regular expressions have distinguished subexpressions. */)
2656 { 2666 {
2657 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2667 unsigned char str[MAX_MULTIBYTE_LENGTH];
2658 const unsigned char *add_stuff = NULL; 2668 const unsigned char *add_stuff = NULL;
2659 int add_len = 0; 2669 EMACS_INT add_len = 0;
2660 int idx = -1; 2670 int idx = -1;
2661 2671
2662 if (str_multibyte) 2672 if (str_multibyte)
@@ -2750,7 +2760,8 @@ since only regular expressions have distinguished subexpressions. */)
2750 { 2760 {
2751 if (buf_multibyte) 2761 if (buf_multibyte)
2752 { 2762 {
2753 int nchars = multibyte_chars_in_text (substed, substed_len); 2763 EMACS_INT nchars =
2764 multibyte_chars_in_text (substed, substed_len);
2754 2765
2755 newtext = make_multibyte_string (substed, nchars, substed_len); 2766 newtext = make_multibyte_string (substed, nchars, substed_len);
2756 } 2767 }
diff --git a/src/syntax.c b/src/syntax.c
index f0a7dca42dc..2f4f5236a40 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -185,7 +185,8 @@ INTERVAL interval_of (int, Lisp_Object);
185 start/end of OBJECT. */ 185 start/end of OBJECT. */
186 186
187void 187void
188update_syntax_table (int charpos, int count, int init, Lisp_Object object) 188update_syntax_table (EMACS_INT charpos, int count, int init,
189 Lisp_Object object)
189{ 190{
190 Lisp_Object tmp_table; 191 Lisp_Object tmp_table;
191 int cnt = 0, invalidate = 1; 192 int cnt = 0, invalidate = 1;
@@ -475,7 +476,7 @@ find_defun_start (EMACS_INT pos, EMACS_INT pos_byte)
475/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ 476/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */
476 477
477static int 478static int
478prev_char_comend_first (int pos, int pos_byte) 479prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte)
479{ 480{
480 int c, val; 481 int c, val;
481 482
@@ -557,8 +558,9 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested
557 that determines quote parity to the comment-end. */ 558 that determines quote parity to the comment-end. */
558 while (from != stop) 559 while (from != stop)
559 { 560 {
560 int temp_byte, prev_syntax; 561 EMACS_INT temp_byte;
561 int com2start, com2end; 562 int prev_syntax, com2start, com2end;
563 int comstart;
562 564
563 /* Move back and examine a character. */ 565 /* Move back and examine a character. */
564 DEC_BOTH (from, from_byte); 566 DEC_BOTH (from, from_byte);
@@ -578,7 +580,8 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested
578 || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); 580 || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested);
579 com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) 581 com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax)
580 && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax)); 582 && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax));
581 583 comstart = (com2start || code == Scomment);
584
582 /* Nasty cases with overlapping 2-char comment markers: 585 /* Nasty cases with overlapping 2-char comment markers:
583 - snmp-mode: -- c -- foo -- c -- 586 - snmp-mode: -- c -- foo -- c --
584 --- c -- 587 --- c --
@@ -589,15 +592,17 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested
589 /// */ 592 /// */
590 593
591 /* If a 2-char comment sequence partly overlaps with another, 594 /* If a 2-char comment sequence partly overlaps with another,
592 we don't try to be clever. */ 595 we don't try to be clever. E.g. |*| in C, or }% in modes that
593 if (from > stop && (com2end || com2start)) 596 have %..\n and %{..}%. */
597 if (from > stop && (com2end || comstart))
594 { 598 {
595 int next = from, next_byte = from_byte, next_c, next_syntax; 599 EMACS_INT next = from, next_byte = from_byte;
600 int next_c, next_syntax;
596 DEC_BOTH (next, next_byte); 601 DEC_BOTH (next, next_byte);
597 UPDATE_SYNTAX_TABLE_BACKWARD (next); 602 UPDATE_SYNTAX_TABLE_BACKWARD (next);
598 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); 603 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte);
599 next_syntax = SYNTAX_WITH_FLAGS (next_c); 604 next_syntax = SYNTAX_WITH_FLAGS (next_c);
600 if (((com2start || comnested) 605 if (((comstart || comnested)
601 && SYNTAX_FLAGS_COMEND_SECOND (syntax) 606 && SYNTAX_FLAGS_COMEND_SECOND (syntax)
602 && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) 607 && SYNTAX_FLAGS_COMEND_FIRST (next_syntax))
603 || ((com2end || comnested) 608 || ((com2end || comnested)
@@ -1239,12 +1244,12 @@ Lisp_Object Vfind_word_boundary_function_table;
1239 If that many words cannot be found before the end of the buffer, return 0. 1244 If that many words cannot be found before the end of the buffer, return 0.
1240 COUNT negative means scan backward and stop at word beginning. */ 1245 COUNT negative means scan backward and stop at word beginning. */
1241 1246
1242int 1247EMACS_INT
1243scan_words (register int from, register int count) 1248scan_words (register EMACS_INT from, register EMACS_INT count)
1244{ 1249{
1245 register int beg = BEGV; 1250 register EMACS_INT beg = BEGV;
1246 register int end = ZV; 1251 register EMACS_INT end = ZV;
1247 register int from_byte = CHAR_TO_BYTE (from); 1252 register EMACS_INT from_byte = CHAR_TO_BYTE (from);
1248 register enum syntaxcode code; 1253 register enum syntaxcode code;
1249 int ch0, ch1; 1254 int ch0, ch1;
1250 Lisp_Object func, script, pos; 1255 Lisp_Object func, script, pos;
@@ -1452,14 +1457,14 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
1452 int *char_ranges; 1457 int *char_ranges;
1453 int n_char_ranges = 0; 1458 int n_char_ranges = 0;
1454 int negate = 0; 1459 int negate = 0;
1455 register int i, i_byte; 1460 register EMACS_INT i, i_byte;
1456 /* Set to 1 if the current buffer is multibyte and the region 1461 /* Set to 1 if the current buffer is multibyte and the region
1457 contains non-ASCII chars. */ 1462 contains non-ASCII chars. */
1458 int multibyte; 1463 int multibyte;
1459 /* Set to 1 if STRING is multibyte and it contains non-ASCII 1464 /* Set to 1 if STRING is multibyte and it contains non-ASCII
1460 chars. */ 1465 chars. */
1461 int string_multibyte; 1466 int string_multibyte;
1462 int size_byte; 1467 EMACS_INT size_byte;
1463 const unsigned char *str; 1468 const unsigned char *str;
1464 int len; 1469 int len;
1465 Lisp_Object iso_classes; 1470 Lisp_Object iso_classes;
@@ -1771,9 +1776,9 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
1771 } 1776 }
1772 1777
1773 { 1778 {
1774 int start_point = PT; 1779 EMACS_INT start_point = PT;
1775 int pos = PT; 1780 EMACS_INT pos = PT;
1776 int pos_byte = PT_BYTE; 1781 EMACS_INT pos_byte = PT_BYTE;
1777 unsigned char *p = PT_ADDR, *endp, *stop; 1782 unsigned char *p = PT_ADDR, *endp, *stop;
1778 1783
1779 if (forwardp) 1784 if (forwardp)
@@ -1943,9 +1948,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim)
1943 register unsigned int c; 1948 register unsigned int c;
1944 unsigned char fastmap[0400]; 1949 unsigned char fastmap[0400];
1945 int negate = 0; 1950 int negate = 0;
1946 register int i, i_byte; 1951 register EMACS_INT i, i_byte;
1947 int multibyte; 1952 int multibyte;
1948 int size_byte; 1953 EMACS_INT size_byte;
1949 unsigned char *str; 1954 unsigned char *str;
1950 1955
1951 CHECK_STRING (string); 1956 CHECK_STRING (string);
@@ -1998,9 +2003,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim)
1998 fastmap[i] ^= 1; 2003 fastmap[i] ^= 1;
1999 2004
2000 { 2005 {
2001 int start_point = PT; 2006 EMACS_INT start_point = PT;
2002 int pos = PT; 2007 EMACS_INT pos = PT;
2003 int pos_byte = PT_BYTE; 2008 EMACS_INT pos_byte = PT_BYTE;
2004 unsigned char *p = PT_ADDR, *endp, *stop; 2009 unsigned char *p = PT_ADDR, *endp, *stop;
2005 2010
2006 if (forwardp) 2011 if (forwardp)
@@ -2391,7 +2396,8 @@ between them, return t; otherwise return nil. */)
2391 if (code == Scomment_fence) 2396 if (code == Scomment_fence)
2392 { 2397 {
2393 /* Skip until first preceding unquoted comment_fence. */ 2398 /* Skip until first preceding unquoted comment_fence. */
2394 int found = 0, ini = from, ini_byte = from_byte; 2399 int found = 0;
2400 EMACS_INT ini = from, ini_byte = from_byte;
2395 2401
2396 while (1) 2402 while (1)
2397 { 2403 {
@@ -2907,11 +2913,11 @@ DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
2907This includes chars with "quote" or "prefix" syntax (' or p). */) 2913This includes chars with "quote" or "prefix" syntax (' or p). */)
2908 (void) 2914 (void)
2909{ 2915{
2910 int beg = BEGV; 2916 EMACS_INT beg = BEGV;
2911 int opoint = PT; 2917 EMACS_INT opoint = PT;
2912 int opoint_byte = PT_BYTE; 2918 EMACS_INT opoint_byte = PT_BYTE;
2913 int pos = PT; 2919 EMACS_INT pos = PT;
2914 int pos_byte = PT_BYTE; 2920 EMACS_INT pos_byte = PT_BYTE;
2915 int c; 2921 int c;
2916 2922
2917 if (pos <= beg) 2923 if (pos <= beg)
diff --git a/src/syntax.h b/src/syntax.h
index 48146572d19..15e6c729308 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21extern Lisp_Object Qsyntax_table_p; 21extern Lisp_Object Qsyntax_table_p;
22extern void update_syntax_table (int, int, int, Lisp_Object); 22extern void update_syntax_table (EMACS_INT, int, int, Lisp_Object);
23 23
24/* The standard syntax table is stored where it will automatically 24/* The standard syntax table is stored where it will automatically
25 be used in all new buffers. */ 25 be used in all new buffers. */
@@ -301,7 +301,7 @@ extern struct gl_state_s gl_state;
301extern int parse_sexp_lookup_properties; 301extern int parse_sexp_lookup_properties;
302extern INTERVAL interval_of (int, Lisp_Object); 302extern INTERVAL interval_of (int, Lisp_Object);
303 303
304extern int scan_words (int, int); 304extern EMACS_INT scan_words (EMACS_INT, EMACS_INT);
305 305
306/* arch-tag: 28833cca-cd73-4741-8c85-a3111166a0e0 306/* arch-tag: 28833cca-cd73-4741-8c85-a3111166a0e0
307 (do not change this comment) */ 307 (do not change this comment) */
diff --git a/src/term.c b/src/term.c
index f090cdd2792..a2f7a9cbabe 100644
--- a/src/term.c
+++ b/src/term.c
@@ -31,10 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <unistd.h> 31#include <unistd.h>
32#endif 32#endif
33 33
34#ifdef HAVE_SYS_IOCTL_H
35#include <sys/ioctl.h>
36#endif
37
38#include <signal.h> 34#include <signal.h>
39#include <stdarg.h> 35#include <stdarg.h>
40#include <setjmp.h> 36#include <setjmp.h>
@@ -247,7 +243,6 @@ tty_set_terminal_modes (struct terminal *terminal)
247 cmputc ('\n'); 243 cmputc ('\n');
248 } 244 }
249 245
250 OUTPUT_IF (tty, tty->TS_termcap_modes);
251 OUTPUT_IF (tty, visible_cursor ? tty->TS_cursor_visible : tty->TS_cursor_normal); 246 OUTPUT_IF (tty, visible_cursor ? tty->TS_cursor_visible : tty->TS_cursor_normal);
252 OUTPUT_IF (tty, tty->TS_keypad_mode); 247 OUTPUT_IF (tty, tty->TS_keypad_mode);
253 losecursor (tty); 248 losecursor (tty);
@@ -599,7 +594,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
599 if (src->u.cmp.automatic) 594 if (src->u.cmp.automatic)
600 { 595 {
601 gstring = composition_gstring_from_id (src->u.cmp.id); 596 gstring = composition_gstring_from_id (src->u.cmp.id);
602 required = src->u.cmp.to + 1 - src->u.cmp.from; 597 required = src->slice.cmp.to + 1 - src->slice.cmp.from;
603 } 598 }
604 else 599 else
605 { 600 {
@@ -616,7 +611,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
616 } 611 }
617 612
618 if (src->u.cmp.automatic) 613 if (src->u.cmp.automatic)
619 for (i = src->u.cmp.from; i <= src->u.cmp.to; i++) 614 for (i = src->slice.cmp.from; i <= src->slice.cmp.to; i++)
620 { 615 {
621 Lisp_Object g = LGSTRING_GLYPH (gstring, i); 616 Lisp_Object g = LGSTRING_GLYPH (gstring, i);
622 int c = LGLYPH_CHAR (g); 617 int c = LGLYPH_CHAR (g);
@@ -1796,8 +1791,8 @@ append_composite_glyph (struct it *it)
1796 { 1791 {
1797 glyph->u.cmp.automatic = 1; 1792 glyph->u.cmp.automatic = 1;
1798 glyph->u.cmp.id = it->cmp_it.id; 1793 glyph->u.cmp.id = it->cmp_it.id;
1799 glyph->u.cmp.from = it->cmp_it.from; 1794 glyph->slice.cmp.from = it->cmp_it.from;
1800 glyph->u.cmp.to = it->cmp_it.to - 1; 1795 glyph->slice.cmp.to = it->cmp_it.to - 1;
1801 } 1796 }
1802 1797
1803 glyph->face_id = it->face_id; 1798 glyph->face_id = it->face_id;
@@ -2619,9 +2614,10 @@ term_clear_mouse_face (void)
2619 If POS is after end of W, return end of last line in W. 2614 If POS is after end of W, return end of last line in W.
2620 - taken from msdos.c */ 2615 - taken from msdos.c */
2621static int 2616static int
2622fast_find_position (struct window *w, int pos, int *hpos, int *vpos) 2617fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos)
2623{ 2618{
2624 int i, lastcol, line_start_position, maybe_next_line_p = 0; 2619 int i, lastcol, maybe_next_line_p = 0;
2620 EMACS_INT line_start_position;
2625 int yb = window_text_bottom_y (w); 2621 int yb = window_text_bottom_y (w);
2626 struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row; 2622 struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
2627 2623
@@ -2659,7 +2655,7 @@ fast_find_position (struct window *w, int pos, int *hpos, int *vpos)
2659 for (i = 0; i < row->used[TEXT_AREA]; i++) 2655 for (i = 0; i < row->used[TEXT_AREA]; i++)
2660 { 2656 {
2661 struct glyph *glyph = row->glyphs[TEXT_AREA] + i; 2657 struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
2662 int charpos; 2658 EMACS_INT charpos;
2663 2659
2664 charpos = glyph->charpos; 2660 charpos = glyph->charpos;
2665 if (charpos == pos) 2661 if (charpos == pos)
@@ -2720,7 +2716,8 @@ term_mouse_highlight (struct frame *f, int x, int y)
2720 && XFASTINT (w->last_modified) == BUF_MODIFF (b) 2716 && XFASTINT (w->last_modified) == BUF_MODIFF (b)
2721 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) 2717 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
2722 { 2718 {
2723 int pos, i, nrows = w->current_matrix->nrows; 2719 int i, nrows = w->current_matrix->nrows;
2720 EMACS_INT pos;
2724 struct glyph_row *row; 2721 struct glyph_row *row;
2725 struct glyph *glyph; 2722 struct glyph *glyph;
2726 2723
@@ -2764,7 +2761,8 @@ term_mouse_highlight (struct frame *f, int x, int y)
2764 /* Check for mouse-face. */ 2761 /* Check for mouse-face. */
2765 { 2762 {
2766 Lisp_Object mouse_face, overlay, position, *overlay_vec; 2763 Lisp_Object mouse_face, overlay, position, *overlay_vec;
2767 int noverlays, obegv, ozv; 2764 int noverlays;
2765 EMACS_INT obegv, ozv;
2768 struct buffer *obuf; 2766 struct buffer *obuf;
2769 2767
2770 /* If we get an out-of-range value, return now; avoid an error. */ 2768 /* If we get an out-of-range value, return now; avoid an error. */
@@ -3405,6 +3403,15 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3405 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 3403 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
3406 Wcm_clear (tty); 3404 Wcm_clear (tty);
3407 3405
3406 encode_terminal_src_size = 0;
3407 encode_terminal_dst_size = 0;
3408
3409#ifdef HAVE_GPM
3410 terminal->mouse_position_hook = term_mouse_position;
3411 mouse_face_window = Qnil;
3412#endif
3413
3414
3408#ifndef DOS_NT 3415#ifndef DOS_NT
3409 set_tty_hooks (terminal); 3416 set_tty_hooks (terminal);
3410 3417
@@ -3458,78 +3465,6 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3458 3465
3459 add_keyboard_wait_descriptor (fileno (tty->input)); 3466 add_keyboard_wait_descriptor (fileno (tty->input));
3460 3467
3461#endif /* !DOS_NT */
3462
3463 encode_terminal_src_size = 0;
3464 encode_terminal_dst_size = 0;
3465
3466#ifdef HAVE_GPM
3467 terminal->mouse_position_hook = term_mouse_position;
3468 mouse_face_window = Qnil;
3469#endif
3470
3471#ifdef DOS_NT
3472#ifdef WINDOWSNT
3473 initialize_w32_display (terminal);
3474#else /* MSDOS */
3475 if (strcmp (terminal_type, "internal") == 0)
3476 terminal->type = output_msdos_raw;
3477 initialize_msdos_display (terminal);
3478#endif /* MSDOS */
3479 tty->output = stdout;
3480 tty->input = stdin;
3481 /* The following two are inaccessible from w32console.c. */
3482 terminal->delete_frame_hook = &tty_free_frame_resources;
3483 terminal->delete_terminal_hook = &delete_tty;
3484
3485 tty->name = xstrdup (name);
3486 terminal->name = xstrdup (name);
3487 tty->type = xstrdup (terminal_type);
3488
3489 add_keyboard_wait_descriptor (0);
3490
3491 Wcm_clear (tty);
3492
3493#ifdef WINDOWSNT
3494 {
3495 struct frame *f = XFRAME (selected_frame);
3496
3497 FrameRows (tty) = FRAME_LINES (f);
3498 FrameCols (tty) = FRAME_COLS (f);
3499 tty->specified_window = FRAME_LINES (f);
3500
3501 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3502 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
3503 }
3504#else /* MSDOS */
3505 {
3506 int height, width;
3507 get_tty_size (fileno (tty->input), &width, &height);
3508 FrameCols (tty) = width;
3509 FrameRows (tty) = height;
3510 }
3511#endif /* MSDOS */
3512 tty->delete_in_insert_mode = 1;
3513
3514 UseTabs (tty) = 0;
3515 terminal->scroll_region_ok = 0;
3516
3517 /* Seems to insert lines when it's not supposed to, messing up the
3518 display. In doing a trace, it didn't seem to be called much, so I
3519 don't think we're losing anything by turning it off. */
3520 terminal->line_ins_del_ok = 0;
3521#ifdef WINDOWSNT
3522 terminal->char_ins_del_ok = 1;
3523 baud_rate = 19200;
3524#else /* MSDOS */
3525 terminal->char_ins_del_ok = 0;
3526 init_baud_rate (fileno (tty->input));
3527#endif /* MSDOS */
3528
3529 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
3530
3531#else /* not DOS_NT */
3532
3533 Wcm_clear (tty); 3468 Wcm_clear (tty);
3534 3469
3535 tty->termcap_term_buffer = (char *) xmalloc (buffer_size); 3470 tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
@@ -3681,7 +3616,64 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3681 tty->TF_underscore = tgetflag ("ul"); 3616 tty->TF_underscore = tgetflag ("ul");
3682 tty->TF_teleray = tgetflag ("xt"); 3617 tty->TF_teleray = tgetflag ("xt");
3683 3618
3684#endif /* !DOS_NT */ 3619#else /* DOS_NT */
3620#ifdef WINDOWSNT
3621 {
3622 struct frame *f = XFRAME (selected_frame);
3623
3624 initialize_w32_display (terminal);
3625
3626 FrameRows (tty) = FRAME_LINES (f);
3627 FrameCols (tty) = FRAME_COLS (f);
3628 tty->specified_window = FRAME_LINES (f);
3629
3630 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3631 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
3632 terminal->char_ins_del_ok = 1;
3633 baud_rate = 19200;
3634 }
3635#else /* MSDOS */
3636 {
3637 int height, width;
3638 if (strcmp (terminal_type, "internal") == 0)
3639 terminal->type = output_msdos_raw;
3640 initialize_msdos_display (terminal);
3641
3642 get_tty_size (fileno (tty->input), &width, &height);
3643 FrameCols (tty) = width;
3644 FrameRows (tty) = height;
3645 terminal->char_ins_del_ok = 0;
3646 init_baud_rate (fileno (tty->input));
3647 }
3648#endif /* MSDOS */
3649 tty->output = stdout;
3650 tty->input = stdin;
3651 /* The following two are inaccessible from w32console.c. */
3652 terminal->delete_frame_hook = &tty_free_frame_resources;
3653 terminal->delete_terminal_hook = &delete_tty;
3654
3655 tty->name = xstrdup (name);
3656 terminal->name = xstrdup (name);
3657 tty->type = xstrdup (terminal_type);
3658
3659 add_keyboard_wait_descriptor (0);
3660
3661 /* FIXME: this should be removed, done earlier. */
3662 Wcm_clear (tty);
3663
3664 tty->delete_in_insert_mode = 1;
3665
3666 UseTabs (tty) = 0;
3667 terminal->scroll_region_ok = 0;
3668
3669 /* Seems to insert lines when it's not supposed to, messing up the
3670 display. In doing a trace, it didn't seem to be called much, so I
3671 don't think we're losing anything by turning it off. */
3672 terminal->line_ins_del_ok = 0;
3673
3674 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
3675#endif /* DOS_NT */
3676
3685 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 3677 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
3686 init_kboard (terminal->kboard); 3678 init_kboard (terminal->kboard);
3687 terminal->kboard->Vwindow_system = Qnil; 3679 terminal->kboard->Vwindow_system = Qnil;
diff --git a/src/termhooks.h b/src/termhooks.h
index 7762dd15efe..b16c36f9551 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -228,9 +228,11 @@ struct input_event
228 /* For an ASCII_KEYSTROKE_EVENT and MULTIBYTE_CHAR_KEYSTROKE_EVENT, 228 /* For an ASCII_KEYSTROKE_EVENT and MULTIBYTE_CHAR_KEYSTROKE_EVENT,
229 this is the character. 229 this is the character.
230 For a NON_ASCII_KEYSTROKE_EVENT, this is the keysym code. 230 For a NON_ASCII_KEYSTROKE_EVENT, this is the keysym code.
231 For a mouse event, this is the button number. */ 231 For a mouse event, this is the button number.
232 For a HELP_EVENT, this is the position within the object
233 (stored in ARG below) where the help was found. */
232 /* In WindowsNT, for a mouse wheel event, this is the delta. */ 234 /* In WindowsNT, for a mouse wheel event, this is the delta. */
233 int code; 235 EMACS_INT code;
234 enum scroll_bar_part part; 236 enum scroll_bar_part part;
235 237
236 int modifiers; /* See enum below for interpretation. */ 238 int modifiers; /* See enum below for interpretation. */
diff --git a/src/textprop.c b/src/textprop.c
index 0e398e41e4a..88e869b13e9 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -125,7 +125,7 @@ INTERVAL
125validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *end, int force) 125validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *end, int force)
126{ 126{
127 register INTERVAL i; 127 register INTERVAL i;
128 int searchpos; 128 EMACS_INT searchpos;
129 129
130 CHECK_STRING_OR_BUFFER (object); 130 CHECK_STRING_OR_BUFFER (object);
131 CHECK_NUMBER_COERCE_MARKER (*begin); 131 CHECK_NUMBER_COERCE_MARKER (*begin);
@@ -161,7 +161,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
161 } 161 }
162 else 162 else
163 { 163 {
164 int len = SCHARS (object); 164 EMACS_INT len = SCHARS (object);
165 165
166 if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end) 166 if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
167 && XINT (*end) <= len)) 167 && XINT (*end) <= len))
@@ -519,7 +519,7 @@ INTERVAL
519interval_of (int position, Lisp_Object object) 519interval_of (int position, Lisp_Object object)
520{ 520{
521 register INTERVAL i; 521 register INTERVAL i;
522 int beg, end; 522 EMACS_INT beg, end;
523 523
524 if (NILP (object)) 524 if (NILP (object))
525 XSETBUFFER (object, current_buffer); 525 XSETBUFFER (object, current_buffer);
@@ -984,7 +984,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
984/* Return 1 if there's a change in some property between BEG and END. */ 984/* Return 1 if there's a change in some property between BEG and END. */
985 985
986int 986int
987property_change_between_p (int beg, int end) 987property_change_between_p (EMACS_INT beg, EMACS_INT end)
988{ 988{
989 register INTERVAL i, next; 989 register INTERVAL i, next;
990 Lisp_Object object, pos; 990 Lisp_Object object, pos;
@@ -1173,7 +1173,8 @@ Return t if any property value actually changed, nil otherwise. */)
1173 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) 1173 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
1174{ 1174{
1175 register INTERVAL i, unchanged; 1175 register INTERVAL i, unchanged;
1176 register int s, len, modified = 0; 1176 register EMACS_INT s, len;
1177 register int modified = 0;
1177 struct gcpro gcpro1; 1178 struct gcpro gcpro1;
1178 1179
1179 properties = validate_plist (properties); 1180 properties = validate_plist (properties);
@@ -1202,7 +1203,7 @@ Return t if any property value actually changed, nil otherwise. */)
1202 skip it. */ 1203 skip it. */
1203 if (interval_has_all_properties (properties, i)) 1204 if (interval_has_all_properties (properties, i))
1204 { 1205 {
1205 int got = (LENGTH (i) - (s - i->position)); 1206 EMACS_INT got = (LENGTH (i) - (s - i->position));
1206 if (got >= len) 1207 if (got >= len)
1207 RETURN_UNGCPRO (Qnil); 1208 RETURN_UNGCPRO (Qnil);
1208 len -= got; 1209 len -= got;
@@ -1377,7 +1378,7 @@ void
1377set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object buffer, INTERVAL i) 1378set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object buffer, INTERVAL i)
1378{ 1379{
1379 register INTERVAL prev_changed = NULL_INTERVAL; 1380 register INTERVAL prev_changed = NULL_INTERVAL;
1380 register int s, len; 1381 register EMACS_INT s, len;
1381 INTERVAL unchanged; 1382 INTERVAL unchanged;
1382 1383
1383 s = XINT (start); 1384 s = XINT (start);
@@ -1466,7 +1467,8 @@ Use `set-text-properties' if you want to remove all text properties. */)
1466 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) 1467 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
1467{ 1468{
1468 register INTERVAL i, unchanged; 1469 register INTERVAL i, unchanged;
1469 register int s, len, modified = 0; 1470 register EMACS_INT s, len;
1471 register int modified = 0;
1470 1472
1471 if (NILP (object)) 1473 if (NILP (object))
1472 XSETBUFFER (object, current_buffer); 1474 XSETBUFFER (object, current_buffer);
@@ -1484,7 +1486,7 @@ Use `set-text-properties' if you want to remove all text properties. */)
1484 it covers the entire region. */ 1486 it covers the entire region. */
1485 if (! interval_has_some_properties (properties, i)) 1487 if (! interval_has_some_properties (properties, i))
1486 { 1488 {
1487 int got = (LENGTH (i) - (s - i->position)); 1489 EMACS_INT got = (LENGTH (i) - (s - i->position));
1488 if (got >= len) 1490 if (got >= len)
1489 return Qnil; 1491 return Qnil;
1490 len -= got; 1492 len -= got;
@@ -1551,7 +1553,8 @@ Return t if any property was actually removed, nil otherwise. */)
1551 (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object) 1553 (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object)
1552{ 1554{
1553 register INTERVAL i, unchanged; 1555 register INTERVAL i, unchanged;
1554 register int s, len, modified = 0; 1556 register EMACS_INT s, len;
1557 register int modified = 0;
1555 Lisp_Object properties; 1558 Lisp_Object properties;
1556 properties = list_of_properties; 1559 properties = list_of_properties;
1557 1560
@@ -1571,7 +1574,7 @@ Return t if any property was actually removed, nil otherwise. */)
1571 it covers the entire region. */ 1574 it covers the entire region. */
1572 if (! interval_has_some_properties_list (properties, i)) 1575 if (! interval_has_some_properties_list (properties, i))
1573 { 1576 {
1574 int got = (LENGTH (i) - (s - i->position)); 1577 EMACS_INT got = (LENGTH (i) - (s - i->position));
1575 if (got >= len) 1578 if (got >= len)
1576 return Qnil; 1579 return Qnil;
1577 len -= got; 1580 len -= got;
@@ -1658,7 +1661,7 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. */
1658 (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object) 1661 (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
1659{ 1662{
1660 register INTERVAL i; 1663 register INTERVAL i;
1661 register int e, pos; 1664 register EMACS_INT e, pos;
1662 1665
1663 if (NILP (object)) 1666 if (NILP (object))
1664 XSETBUFFER (object, current_buffer); 1667 XSETBUFFER (object, current_buffer);
@@ -1694,7 +1697,7 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. */
1694 (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object) 1697 (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
1695{ 1698{
1696 register INTERVAL i; 1699 register INTERVAL i;
1697 register int s, e; 1700 register EMACS_INT s, e;
1698 1701
1699 if (NILP (object)) 1702 if (NILP (object))
1700 XSETBUFFER (object, current_buffer); 1703 XSETBUFFER (object, current_buffer);
@@ -1806,7 +1809,8 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_
1806 Lisp_Object res; 1809 Lisp_Object res;
1807 Lisp_Object stuff; 1810 Lisp_Object stuff;
1808 Lisp_Object plist; 1811 Lisp_Object plist;
1809 int s, e, e2, p, len, modified = 0; 1812 EMACS_INT s, e, e2, p, len;
1813 int modified = 0;
1810 struct gcpro gcpro1, gcpro2; 1814 struct gcpro gcpro1, gcpro2;
1811 1815
1812 i = validate_interval_range (src, &start, &end, soft); 1816 i = validate_interval_range (src, &start, &end, soft);
@@ -1902,12 +1906,12 @@ text_property_list (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp
1902 i = validate_interval_range (object, &start, &end, soft); 1906 i = validate_interval_range (object, &start, &end, soft);
1903 if (!NULL_INTERVAL_P (i)) 1907 if (!NULL_INTERVAL_P (i))
1904 { 1908 {
1905 int s = XINT (start); 1909 EMACS_INT s = XINT (start);
1906 int e = XINT (end); 1910 EMACS_INT e = XINT (end);
1907 1911
1908 while (s < e) 1912 while (s < e)
1909 { 1913 {
1910 int interval_end, len; 1914 EMACS_INT interval_end, len;
1911 Lisp_Object plist; 1915 Lisp_Object plist;
1912 1916
1913 interval_end = i->position + LENGTH (i); 1917 interval_end = i->position + LENGTH (i);
@@ -1985,7 +1989,7 @@ Lisp_Object
1985extend_property_ranges (Lisp_Object list, Lisp_Object new_end) 1989extend_property_ranges (Lisp_Object list, Lisp_Object new_end)
1986{ 1990{
1987 Lisp_Object prev = Qnil, head = list; 1991 Lisp_Object prev = Qnil, head = list;
1988 int max = XINT (new_end); 1992 EMACS_INT max = XINT (new_end);
1989 1993
1990 for (; CONSP (list); prev = list, list = XCDR (list)) 1994 for (; CONSP (list); prev = list, list = XCDR (list))
1991 { 1995 {
@@ -2059,7 +2063,7 @@ verify_interval_modification (struct buffer *buf, int start, int end)
2059 2063
2060 if (start > end) 2064 if (start > end)
2061 { 2065 {
2062 int temp = start; 2066 EMACS_INT temp = start;
2063 start = end; 2067 start = end;
2064 end = temp; 2068 end = temp;
2065 } 2069 }
diff --git a/src/undo.c b/src/undo.c
index 14a8268394a..cd3ad97349b 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -67,7 +67,7 @@ int undo_inhibit_record_point;
67 undo record that will be added just after this command terminates. */ 67 undo record that will be added just after this command terminates. */
68 68
69static void 69static void
70record_point (int pt) 70record_point (EMACS_INT pt)
71{ 71{
72 int at_boundary; 72 int at_boundary;
73 73
@@ -129,7 +129,7 @@ record_point (int pt)
129 because we don't need to record the contents.) */ 129 because we don't need to record the contents.) */
130 130
131void 131void
132record_insert (int beg, int length) 132record_insert (EMACS_INT beg, EMACS_INT length)
133{ 133{
134 Lisp_Object lbeg, lend; 134 Lisp_Object lbeg, lend;
135 135
@@ -164,7 +164,7 @@ record_insert (int beg, int length)
164 of the characters in STRING, at location BEG. */ 164 of the characters in STRING, at location BEG. */
165 165
166void 166void
167record_delete (int beg, Lisp_Object string) 167record_delete (EMACS_INT beg, Lisp_Object string)
168{ 168{
169 Lisp_Object sbeg; 169 Lisp_Object sbeg;
170 170
@@ -192,7 +192,7 @@ record_delete (int beg, Lisp_Object string)
192 won't be inverted automatically by undoing the buffer modification. */ 192 won't be inverted automatically by undoing the buffer modification. */
193 193
194void 194void
195record_marker_adjustment (Lisp_Object marker, int adjustment) 195record_marker_adjustment (Lisp_Object marker, EMACS_INT adjustment)
196{ 196{
197 if (EQ (current_buffer->undo_list, Qt)) 197 if (EQ (current_buffer->undo_list, Qt))
198 return; 198 return;
@@ -215,7 +215,7 @@ record_marker_adjustment (Lisp_Object marker, int adjustment)
215 The replacement must not change the number of characters. */ 215 The replacement must not change the number of characters. */
216 216
217void 217void
218record_change (int beg, int length) 218record_change (EMACS_INT beg, EMACS_INT length)
219{ 219{
220 record_delete (beg, make_buffer_string (beg, beg + length, 1)); 220 record_delete (beg, make_buffer_string (beg, beg + length, 1));
221 record_insert (beg, length); 221 record_insert (beg, length);
@@ -250,7 +250,9 @@ record_first_change (void)
250 for LENGTH characters starting at position BEG in BUFFER. */ 250 for LENGTH characters starting at position BEG in BUFFER. */
251 251
252void 252void
253record_property_change (int beg, int length, Lisp_Object prop, Lisp_Object value, Lisp_Object buffer) 253record_property_change (EMACS_INT beg, EMACS_INT length,
254 Lisp_Object prop, Lisp_Object value,
255 Lisp_Object buffer)
254{ 256{
255 Lisp_Object lbeg, lend, entry; 257 Lisp_Object lbeg, lend, entry;
256 struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer); 258 struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer);
@@ -601,7 +603,7 @@ Return what remains of the list. */)
601 { 603 {
602 /* Element (STRING . POS) means STRING was deleted. */ 604 /* Element (STRING . POS) means STRING was deleted. */
603 Lisp_Object membuf; 605 Lisp_Object membuf;
604 int pos = XINT (cdr); 606 EMACS_INT pos = XINT (cdr);
605 607
606 membuf = car; 608 membuf = car;
607 if (pos < 0) 609 if (pos < 0)
diff --git a/src/w32.c b/src/w32.c
index f1ed6ae0be9..4ccda449b47 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -78,15 +78,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
78/* Some versions of compiler define MEMORYSTATUSEX, some don't, so we 78/* Some versions of compiler define MEMORYSTATUSEX, some don't, so we
79 use a different name to avoid compilation problems. */ 79 use a different name to avoid compilation problems. */
80typedef struct _MEMORY_STATUS_EX { 80typedef struct _MEMORY_STATUS_EX {
81 DWORD dwLength; 81 DWORD dwLength;
82 DWORD dwMemoryLoad; 82 DWORD dwMemoryLoad;
83 DWORDLONG ullTotalPhys; 83 DWORDLONG ullTotalPhys;
84 DWORDLONG ullAvailPhys; 84 DWORDLONG ullAvailPhys;
85 DWORDLONG ullTotalPageFile; 85 DWORDLONG ullTotalPageFile;
86 DWORDLONG ullAvailPageFile; 86 DWORDLONG ullAvailPageFile;
87 DWORDLONG ullTotalVirtual; 87 DWORDLONG ullTotalVirtual;
88 DWORDLONG ullAvailVirtual; 88 DWORDLONG ullAvailVirtual;
89 DWORDLONG ullAvailExtendedVirtual; 89 DWORDLONG ullAvailExtendedVirtual;
90} MEMORY_STATUS_EX,*LPMEMORY_STATUS_EX; 90} MEMORY_STATUS_EX,*LPMEMORY_STATUS_EX;
91 91
92#include <lmcons.h> 92#include <lmcons.h>
@@ -94,23 +94,27 @@ typedef struct _MEMORY_STATUS_EX {
94 94
95#include <tlhelp32.h> 95#include <tlhelp32.h>
96#include <psapi.h> 96#include <psapi.h>
97#include <w32api.h>
98#if !defined(__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
97/* This either is not in psapi.h or guarded by higher value of 99/* This either is not in psapi.h or guarded by higher value of
98 _WIN32_WINNT than what we use. */ 100 _WIN32_WINNT than what we use. w32api suplied with MinGW 3.15
101 defines it in psapi.h */
99typedef struct _PROCESS_MEMORY_COUNTERS_EX { 102typedef struct _PROCESS_MEMORY_COUNTERS_EX {
100 DWORD cb; 103 DWORD cb;
101 DWORD PageFaultCount; 104 DWORD PageFaultCount;
102 DWORD PeakWorkingSetSize; 105 DWORD PeakWorkingSetSize;
103 DWORD WorkingSetSize; 106 DWORD WorkingSetSize;
104 DWORD QuotaPeakPagedPoolUsage; 107 DWORD QuotaPeakPagedPoolUsage;
105 DWORD QuotaPagedPoolUsage; 108 DWORD QuotaPagedPoolUsage;
106 DWORD QuotaPeakNonPagedPoolUsage; 109 DWORD QuotaPeakNonPagedPoolUsage;
107 DWORD QuotaNonPagedPoolUsage; 110 DWORD QuotaNonPagedPoolUsage;
108 DWORD PagefileUsage; 111 DWORD PagefileUsage;
109 DWORD PeakPagefileUsage; 112 DWORD PeakPagefileUsage;
110 DWORD PrivateUsage; 113 DWORD PrivateUsage;
111} PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; 114} PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX;
115#endif
112 116
113#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ 117/* TCP connection support. */
114#include <sys/socket.h> 118#include <sys/socket.h>
115#undef socket 119#undef socket
116#undef bind 120#undef bind
@@ -129,7 +133,6 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
129#undef accept 133#undef accept
130#undef recvfrom 134#undef recvfrom
131#undef sendto 135#undef sendto
132#endif
133 136
134#include "w32.h" 137#include "w32.h"
135#include "ndir.h" 138#include "ndir.h"
@@ -169,7 +172,6 @@ static BOOL g_b_init_is_windows_9x;
169static BOOL g_b_init_open_process_token; 172static BOOL g_b_init_open_process_token;
170static BOOL g_b_init_get_token_information; 173static BOOL g_b_init_get_token_information;
171static BOOL g_b_init_lookup_account_sid; 174static BOOL g_b_init_lookup_account_sid;
172static BOOL g_b_init_get_sid_identifier_authority;
173static BOOL g_b_init_get_sid_sub_authority; 175static BOOL g_b_init_get_sid_sub_authority;
174static BOOL g_b_init_get_sid_sub_authority_count; 176static BOOL g_b_init_get_sid_sub_authority_count;
175static BOOL g_b_init_get_file_security; 177static BOOL g_b_init_get_file_security;
@@ -232,8 +234,6 @@ typedef BOOL (WINAPI * LookupAccountSid_Proc) (
232 LPTSTR DomainName, 234 LPTSTR DomainName,
233 LPDWORD cbDomainName, 235 LPDWORD cbDomainName,
234 PSID_NAME_USE peUse); 236 PSID_NAME_USE peUse);
235typedef PSID_IDENTIFIER_AUTHORITY (WINAPI * GetSidIdentifierAuthority_Proc) (
236 PSID pSid);
237typedef PDWORD (WINAPI * GetSidSubAuthority_Proc) ( 237typedef PDWORD (WINAPI * GetSidSubAuthority_Proc) (
238 PSID pSid, 238 PSID pSid,
239 DWORD n); 239 DWORD n);
@@ -300,13 +300,11 @@ typedef BOOL (WINAPI * GetSystemTimes_Proc) (
300 LPFILETIME lpKernelTime, 300 LPFILETIME lpKernelTime,
301 LPFILETIME lpUserTime); 301 LPFILETIME lpUserTime);
302 302
303
304
305 /* ** A utility function ** */ 303 /* ** A utility function ** */
306static BOOL 304static BOOL
307is_windows_9x (void) 305is_windows_9x (void)
308{ 306{
309 static BOOL s_b_ret=0; 307 static BOOL s_b_ret = 0;
310 OSVERSIONINFO os_ver; 308 OSVERSIONINFO os_ver;
311 if (g_b_init_is_windows_9x == 0) 309 if (g_b_init_is_windows_9x == 0)
312 { 310 {
@@ -363,10 +361,10 @@ w32_get_internal_run_time (void)
363 361
364 /* ** The wrapper functions ** */ 362 /* ** The wrapper functions ** */
365 363
366BOOL WINAPI open_process_token ( 364static BOOL WINAPI
367 HANDLE ProcessHandle, 365open_process_token (HANDLE ProcessHandle,
368 DWORD DesiredAccess, 366 DWORD DesiredAccess,
369 PHANDLE TokenHandle) 367 PHANDLE TokenHandle)
370{ 368{
371 static OpenProcessToken_Proc s_pfn_Open_Process_Token = NULL; 369 static OpenProcessToken_Proc s_pfn_Open_Process_Token = NULL;
372 HMODULE hm_advapi32 = NULL; 370 HMODULE hm_advapi32 = NULL;
@@ -393,12 +391,12 @@ BOOL WINAPI open_process_token (
393 ); 391 );
394} 392}
395 393
396BOOL WINAPI get_token_information ( 394static BOOL WINAPI
397 HANDLE TokenHandle, 395get_token_information (HANDLE TokenHandle,
398 TOKEN_INFORMATION_CLASS TokenInformationClass, 396 TOKEN_INFORMATION_CLASS TokenInformationClass,
399 LPVOID TokenInformation, 397 LPVOID TokenInformation,
400 DWORD TokenInformationLength, 398 DWORD TokenInformationLength,
401 PDWORD ReturnLength) 399 PDWORD ReturnLength)
402{ 400{
403 static GetTokenInformation_Proc s_pfn_Get_Token_Information = NULL; 401 static GetTokenInformation_Proc s_pfn_Get_Token_Information = NULL;
404 HMODULE hm_advapi32 = NULL; 402 HMODULE hm_advapi32 = NULL;
@@ -427,14 +425,14 @@ BOOL WINAPI get_token_information (
427 ); 425 );
428} 426}
429 427
430BOOL WINAPI lookup_account_sid ( 428static BOOL WINAPI
431 LPCTSTR lpSystemName, 429lookup_account_sid (LPCTSTR lpSystemName,
432 PSID Sid, 430 PSID Sid,
433 LPTSTR Name, 431 LPTSTR Name,
434 LPDWORD cbName, 432 LPDWORD cbName,
435 LPTSTR DomainName, 433 LPTSTR DomainName,
436 LPDWORD cbDomainName, 434 LPDWORD cbDomainName,
437 PSID_NAME_USE peUse) 435 PSID_NAME_USE peUse)
438{ 436{
439 static LookupAccountSid_Proc s_pfn_Lookup_Account_Sid = NULL; 437 static LookupAccountSid_Proc s_pfn_Lookup_Account_Sid = NULL;
440 HMODULE hm_advapi32 = NULL; 438 HMODULE hm_advapi32 = NULL;
@@ -465,33 +463,8 @@ BOOL WINAPI lookup_account_sid (
465 ); 463 );
466} 464}
467 465
468PSID_IDENTIFIER_AUTHORITY WINAPI get_sid_identifier_authority ( 466static PDWORD WINAPI
469 PSID pSid) 467get_sid_sub_authority (PSID pSid, DWORD n)
470{
471 static GetSidIdentifierAuthority_Proc s_pfn_Get_Sid_Identifier_Authority = NULL;
472 HMODULE hm_advapi32 = NULL;
473 if (is_windows_9x () == TRUE)
474 {
475 return NULL;
476 }
477 if (g_b_init_get_sid_identifier_authority == 0)
478 {
479 g_b_init_get_sid_identifier_authority = 1;
480 hm_advapi32 = LoadLibrary ("Advapi32.dll");
481 s_pfn_Get_Sid_Identifier_Authority =
482 (GetSidIdentifierAuthority_Proc) GetProcAddress (
483 hm_advapi32, "GetSidIdentifierAuthority");
484 }
485 if (s_pfn_Get_Sid_Identifier_Authority == NULL)
486 {
487 return NULL;
488 }
489 return (s_pfn_Get_Sid_Identifier_Authority (pSid));
490}
491
492PDWORD WINAPI get_sid_sub_authority (
493 PSID pSid,
494 DWORD n)
495{ 468{
496 static GetSidSubAuthority_Proc s_pfn_Get_Sid_Sub_Authority = NULL; 469 static GetSidSubAuthority_Proc s_pfn_Get_Sid_Sub_Authority = NULL;
497 static DWORD zero = 0U; 470 static DWORD zero = 0U;
@@ -515,8 +488,8 @@ PDWORD WINAPI get_sid_sub_authority (
515 return (s_pfn_Get_Sid_Sub_Authority (pSid, n)); 488 return (s_pfn_Get_Sid_Sub_Authority (pSid, n));
516} 489}
517 490
518PUCHAR WINAPI get_sid_sub_authority_count ( 491static PUCHAR WINAPI
519 PSID pSid) 492get_sid_sub_authority_count (PSID pSid)
520{ 493{
521 static GetSidSubAuthorityCount_Proc s_pfn_Get_Sid_Sub_Authority_Count = NULL; 494 static GetSidSubAuthorityCount_Proc s_pfn_Get_Sid_Sub_Authority_Count = NULL;
522 static UCHAR zero = 0U; 495 static UCHAR zero = 0U;
@@ -540,12 +513,12 @@ PUCHAR WINAPI get_sid_sub_authority_count (
540 return (s_pfn_Get_Sid_Sub_Authority_Count (pSid)); 513 return (s_pfn_Get_Sid_Sub_Authority_Count (pSid));
541} 514}
542 515
543BOOL WINAPI get_file_security ( 516static BOOL WINAPI
544 LPCTSTR lpFileName, 517get_file_security (LPCTSTR lpFileName,
545 SECURITY_INFORMATION RequestedInformation, 518 SECURITY_INFORMATION RequestedInformation,
546 PSECURITY_DESCRIPTOR pSecurityDescriptor, 519 PSECURITY_DESCRIPTOR pSecurityDescriptor,
547 DWORD nLength, 520 DWORD nLength,
548 LPDWORD lpnLengthNeeded) 521 LPDWORD lpnLengthNeeded)
549{ 522{
550 static GetFileSecurity_Proc s_pfn_Get_File_Security = NULL; 523 static GetFileSecurity_Proc s_pfn_Get_File_Security = NULL;
551 HMODULE hm_advapi32 = NULL; 524 HMODULE hm_advapi32 = NULL;
@@ -570,10 +543,10 @@ BOOL WINAPI get_file_security (
570 lpnLengthNeeded)); 543 lpnLengthNeeded));
571} 544}
572 545
573BOOL WINAPI get_security_descriptor_owner ( 546static BOOL WINAPI
574 PSECURITY_DESCRIPTOR pSecurityDescriptor, 547get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor,
575 PSID *pOwner, 548 PSID *pOwner,
576 LPBOOL lpbOwnerDefaulted) 549 LPBOOL lpbOwnerDefaulted)
577{ 550{
578 static GetSecurityDescriptorOwner_Proc s_pfn_Get_Security_Descriptor_Owner = NULL; 551 static GetSecurityDescriptorOwner_Proc s_pfn_Get_Security_Descriptor_Owner = NULL;
579 HMODULE hm_advapi32 = NULL; 552 HMODULE hm_advapi32 = NULL;
@@ -597,10 +570,10 @@ BOOL WINAPI get_security_descriptor_owner (
597 lpbOwnerDefaulted)); 570 lpbOwnerDefaulted));
598} 571}
599 572
600BOOL WINAPI get_security_descriptor_group ( 573static BOOL WINAPI
601 PSECURITY_DESCRIPTOR pSecurityDescriptor, 574get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor,
602 PSID *pGroup, 575 PSID *pGroup,
603 LPBOOL lpbGroupDefaulted) 576 LPBOOL lpbGroupDefaulted)
604{ 577{
605 static GetSecurityDescriptorGroup_Proc s_pfn_Get_Security_Descriptor_Group = NULL; 578 static GetSecurityDescriptorGroup_Proc s_pfn_Get_Security_Descriptor_Group = NULL;
606 HMODULE hm_advapi32 = NULL; 579 HMODULE hm_advapi32 = NULL;
@@ -624,8 +597,8 @@ BOOL WINAPI get_security_descriptor_group (
624 lpbGroupDefaulted)); 597 lpbGroupDefaulted));
625} 598}
626 599
627BOOL WINAPI is_valid_sid ( 600static BOOL WINAPI
628 PSID sid) 601is_valid_sid (PSID sid)
629{ 602{
630 static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL; 603 static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL;
631 HMODULE hm_advapi32 = NULL; 604 HMODULE hm_advapi32 = NULL;
@@ -648,9 +621,8 @@ BOOL WINAPI is_valid_sid (
648 return (s_pfn_Is_Valid_Sid (sid)); 621 return (s_pfn_Is_Valid_Sid (sid));
649} 622}
650 623
651BOOL WINAPI equal_sid ( 624static BOOL WINAPI
652 PSID sid1, 625equal_sid (PSID sid1, PSID sid2)
653 PSID sid2)
654{ 626{
655 static EqualSid_Proc s_pfn_Equal_Sid = NULL; 627 static EqualSid_Proc s_pfn_Equal_Sid = NULL;
656 HMODULE hm_advapi32 = NULL; 628 HMODULE hm_advapi32 = NULL;
@@ -673,8 +645,8 @@ BOOL WINAPI equal_sid (
673 return (s_pfn_Equal_Sid (sid1, sid2)); 645 return (s_pfn_Equal_Sid (sid1, sid2));
674} 646}
675 647
676DWORD WINAPI get_length_sid ( 648static DWORD WINAPI
677 PSID sid) 649get_length_sid (PSID sid)
678{ 650{
679 static GetLengthSid_Proc s_pfn_Get_Length_Sid = NULL; 651 static GetLengthSid_Proc s_pfn_Get_Length_Sid = NULL;
680 HMODULE hm_advapi32 = NULL; 652 HMODULE hm_advapi32 = NULL;
@@ -697,10 +669,8 @@ DWORD WINAPI get_length_sid (
697 return (s_pfn_Get_Length_Sid (sid)); 669 return (s_pfn_Get_Length_Sid (sid));
698} 670}
699 671
700BOOL WINAPI copy_sid ( 672static BOOL WINAPI
701 DWORD destlen, 673copy_sid (DWORD destlen, PSID dest, PSID src)
702 PSID dest,
703 PSID src)
704{ 674{
705 static CopySid_Proc s_pfn_Copy_Sid = NULL; 675 static CopySid_Proc s_pfn_Copy_Sid = NULL;
706 HMODULE hm_advapi32 = NULL; 676 HMODULE hm_advapi32 = NULL;
@@ -729,8 +699,8 @@ BOOL WINAPI copy_sid (
729 supported in Windows NT / 2k / XP 699 supported in Windows NT / 2k / XP
730*/ 700*/
731 701
732void WINAPI get_native_system_info ( 702static void WINAPI
733 LPSYSTEM_INFO lpSystemInfo) 703get_native_system_info (LPSYSTEM_INFO lpSystemInfo)
734{ 704{
735 static GetNativeSystemInfo_Proc s_pfn_Get_Native_System_Info = NULL; 705 static GetNativeSystemInfo_Proc s_pfn_Get_Native_System_Info = NULL;
736 if (is_windows_9x () != TRUE) 706 if (is_windows_9x () != TRUE)
@@ -749,10 +719,10 @@ void WINAPI get_native_system_info (
749 lpSystemInfo->dwNumberOfProcessors = -1; 719 lpSystemInfo->dwNumberOfProcessors = -1;
750} 720}
751 721
752BOOL WINAPI get_system_times ( 722static BOOL WINAPI
753 LPFILETIME lpIdleTime, 723get_system_times (LPFILETIME lpIdleTime,
754 LPFILETIME lpKernelTime, 724 LPFILETIME lpKernelTime,
755 LPFILETIME lpUserTime) 725 LPFILETIME lpUserTime)
756{ 726{
757 static GetSystemTimes_Proc s_pfn_Get_System_times = NULL; 727 static GetSystemTimes_Proc s_pfn_Get_System_times = NULL;
758 if (is_windows_9x () == TRUE) 728 if (is_windows_9x () == TRUE)
@@ -830,17 +800,6 @@ getwd (char *dir)
830#endif 800#endif
831} 801}
832 802
833#ifndef HAVE_SOCKETS
834/* Emulate gethostname. */
835int
836gethostname (char *buffer, int size)
837{
838 /* NT only allows small host names, so the buffer is
839 certainly large enough. */
840 return !GetComputerName (buffer, &size);
841}
842#endif /* HAVE_SOCKETS */
843
844/* Emulate getloadavg. */ 803/* Emulate getloadavg. */
845 804
846struct load_sample { 805struct load_sample {
@@ -1086,7 +1045,7 @@ getpwnam (char *name)
1086 return pw; 1045 return pw;
1087} 1046}
1088 1047
1089void 1048static void
1090init_user_info (void) 1049init_user_info (void)
1091{ 1050{
1092 /* Find the user's real name by opening the process token and 1051 /* Find the user's real name by opening the process token and
@@ -1292,7 +1251,7 @@ unixtodos_filename (register char *p)
1292/* Remove all CR's that are followed by a LF. 1251/* Remove all CR's that are followed by a LF.
1293 (From msdos.c...probably should figure out a way to share it, 1252 (From msdos.c...probably should figure out a way to share it,
1294 although this code isn't going to ever change.) */ 1253 although this code isn't going to ever change.) */
1295int 1254static int
1296crlf_to_lf (register int n, register unsigned char *buf) 1255crlf_to_lf (register int n, register unsigned char *buf)
1297{ 1256{
1298 unsigned char *np = buf; 1257 unsigned char *np = buf;
@@ -1431,7 +1390,7 @@ w32_get_long_filename (char * name, char * buf, int size)
1431 return TRUE; 1390 return TRUE;
1432} 1391}
1433 1392
1434int 1393static int
1435is_unc_volume (const char *filename) 1394is_unc_volume (const char *filename)
1436{ 1395{
1437 const char *ptr = filename; 1396 const char *ptr = filename;
@@ -1933,7 +1892,25 @@ get_emacs_configuration (void)
1933char * 1892char *
1934get_emacs_configuration_options (void) 1893get_emacs_configuration_options (void)
1935{ 1894{
1936 static char options_buffer[256]; 1895 static char *options_buffer;
1896 char cv[32]; /* Enough for COMPILER_VERSION. */
1897 char *options[] = {
1898 cv, /* To be filled later. */
1899#ifdef EMACSDEBUG
1900 " --no-opt",
1901#endif
1902 /* configure.bat already sets USER_CFLAGS and USER_LDFLAGS
1903 with a starting space to save work here. */
1904#ifdef USER_CFLAGS
1905 " --cflags", USER_CFLAGS,
1906#endif
1907#ifdef USER_LDFLAGS
1908 " --ldflags", USER_LDFLAGS,
1909#endif
1910 NULL
1911 };
1912 size_t size = 0;
1913 int i;
1937 1914
1938/* Work out the effective configure options for this build. */ 1915/* Work out the effective configure options for this build. */
1939#ifdef _MSC_VER 1916#ifdef _MSC_VER
@@ -1946,18 +1923,19 @@ get_emacs_configuration_options (void)
1946#endif 1923#endif
1947#endif 1924#endif
1948 1925
1949 sprintf (options_buffer, COMPILER_VERSION); 1926 if (_snprintf (cv, sizeof (cv) - 1, COMPILER_VERSION) < 0)
1950#ifdef EMACSDEBUG 1927 return "Error: not enough space for compiler version";
1951 strcat (options_buffer, " --no-opt"); 1928 cv[sizeof (cv) - 1] = '\0';
1952#endif 1929
1953#ifdef USER_CFLAGS 1930 for (i = 0; options[i]; i++)
1954 strcat (options_buffer, " --cflags"); 1931 size += strlen (options[i]);
1955 strcat (options_buffer, USER_CFLAGS); 1932
1956#endif 1933 options_buffer = xmalloc (size + 1);
1957#ifdef USER_LDFLAGS 1934 options_buffer[0] = '\0';
1958 strcat (options_buffer, " --ldflags"); 1935
1959 strcat (options_buffer, USER_LDFLAGS); 1936 for (i = 0; options[i]; i++)
1960#endif 1937 strcat (options_buffer, options[i]);
1938
1961 return options_buffer; 1939 return options_buffer;
1962} 1940}
1963 1941
@@ -2068,7 +2046,7 @@ add_volume_info (char * root_dir, volume_info_data * info)
2068/* Wrapper for GetVolumeInformation, which uses caching to avoid 2046/* Wrapper for GetVolumeInformation, which uses caching to avoid
2069 performance penalty (~2ms on 486 for local drives, 7.5ms for local 2047 performance penalty (~2ms on 486 for local drives, 7.5ms for local
2070 cdrom drive, ~5-10ms or more for remote drives on LAN). */ 2048 cdrom drive, ~5-10ms or more for remote drives on LAN). */
2071volume_info_data * 2049static volume_info_data *
2072GetCachedVolumeInformation (char * root_dir) 2050GetCachedVolumeInformation (char * root_dir)
2073{ 2051{
2074 volume_info_data * info; 2052 volume_info_data * info;
@@ -2159,7 +2137,7 @@ GetCachedVolumeInformation (char * root_dir)
2159 2137
2160/* Get information on the volume where name is held; set path pointer to 2138/* Get information on the volume where name is held; set path pointer to
2161 start of pathname in name (past UNC header\volume header if present). */ 2139 start of pathname in name (past UNC header\volume header if present). */
2162int 2140static int
2163get_volume_info (const char * name, const char ** pPath) 2141get_volume_info (const char * name, const char ** pPath)
2164{ 2142{
2165 char temp[MAX_PATH]; 2143 char temp[MAX_PATH];
@@ -2210,7 +2188,7 @@ get_volume_info (const char * name, const char ** pPath)
2210 2188
2211/* Determine if volume is FAT format (ie. only supports short 8.3 2189/* Determine if volume is FAT format (ie. only supports short 8.3
2212 names); also set path pointer to start of pathname in name. */ 2190 names); also set path pointer to start of pathname in name. */
2213int 2191static int
2214is_fat_volume (const char * name, const char ** pPath) 2192is_fat_volume (const char * name, const char ** pPath)
2215{ 2193{
2216 if (get_volume_info (name, pPath)) 2194 if (get_volume_info (name, pPath))
@@ -2348,9 +2326,9 @@ static WIN32_FIND_DATA dir_find_data;
2348/* Support shares on a network resource as subdirectories of a read-only 2326/* Support shares on a network resource as subdirectories of a read-only
2349 root directory. */ 2327 root directory. */
2350static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE; 2328static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE;
2351HANDLE open_unc_volume (const char *); 2329static HANDLE open_unc_volume (const char *);
2352char *read_unc_volume (HANDLE, char *, int); 2330static char *read_unc_volume (HANDLE, char *, int);
2353void close_unc_volume (HANDLE); 2331static void close_unc_volume (HANDLE);
2354 2332
2355DIR * 2333DIR *
2356opendir (char *filename) 2334opendir (char *filename)
@@ -2486,7 +2464,7 @@ readdir (DIR *dirp)
2486 return &dir_static; 2464 return &dir_static;
2487} 2465}
2488 2466
2489HANDLE 2467static HANDLE
2490open_unc_volume (const char *path) 2468open_unc_volume (const char *path)
2491{ 2469{
2492 NETRESOURCE nr; 2470 NETRESOURCE nr;
@@ -2511,7 +2489,7 @@ open_unc_volume (const char *path)
2511 return INVALID_HANDLE_VALUE; 2489 return INVALID_HANDLE_VALUE;
2512} 2490}
2513 2491
2514char * 2492static char *
2515read_unc_volume (HANDLE henum, char *readbuf, int size) 2493read_unc_volume (HANDLE henum, char *readbuf, int size)
2516{ 2494{
2517 DWORD count; 2495 DWORD count;
@@ -2536,14 +2514,14 @@ read_unc_volume (HANDLE henum, char *readbuf, int size)
2536 return readbuf; 2514 return readbuf;
2537} 2515}
2538 2516
2539void 2517static void
2540close_unc_volume (HANDLE henum) 2518close_unc_volume (HANDLE henum)
2541{ 2519{
2542 if (henum != INVALID_HANDLE_VALUE) 2520 if (henum != INVALID_HANDLE_VALUE)
2543 WNetCloseEnum (henum); 2521 WNetCloseEnum (henum);
2544} 2522}
2545 2523
2546DWORD 2524static DWORD
2547unc_volume_file_attributes (const char *path) 2525unc_volume_file_attributes (const char *path)
2548{ 2526{
2549 HANDLE henum; 2527 HANDLE henum;
@@ -3003,8 +2981,7 @@ convert_time (FILETIME ft)
3003 return (time_t) ((tmp - utc_base) / 10000000L); 2981 return (time_t) ((tmp - utc_base) / 10000000L);
3004} 2982}
3005 2983
3006 2984static void
3007void
3008convert_from_time_t (time_t time, FILETIME * pft) 2985convert_from_time_t (time_t time, FILETIME * pft)
3009{ 2986{
3010 ULARGE_INTEGER tmp; 2987 ULARGE_INTEGER tmp;
@@ -3225,10 +3202,9 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
3225} 3202}
3226 3203
3227static void 3204static void
3228get_file_owner_and_group ( 3205get_file_owner_and_group (PSECURITY_DESCRIPTOR psd,
3229 PSECURITY_DESCRIPTOR psd, 3206 const char *fname,
3230 const char *fname, 3207 struct stat *st)
3231 struct stat *st)
3232{ 3208{
3233 int dflt_usr = 0, dflt_grp = 0; 3209 int dflt_usr = 0, dflt_grp = 0;
3234 3210
@@ -3481,7 +3457,6 @@ stat (const char * path, struct stat * buf)
3481 buf->st_dev = volume_info.serialnum; 3457 buf->st_dev = volume_info.serialnum;
3482 buf->st_rdev = volume_info.serialnum; 3458 buf->st_rdev = volume_info.serialnum;
3483 3459
3484
3485 buf->st_size = wfd.nFileSizeHigh; 3460 buf->st_size = wfd.nFileSizeHigh;
3486 buf->st_size <<= 32; 3461 buf->st_size <<= 32;
3487 buf->st_size += wfd.nFileSizeLow; 3462 buf->st_size += wfd.nFileSizeLow;
@@ -3654,9 +3629,8 @@ utime (const char *name, struct utimbuf *times)
3654 3629
3655/* Helper wrapper functions. */ 3630/* Helper wrapper functions. */
3656 3631
3657HANDLE WINAPI create_toolhelp32_snapshot ( 3632static HANDLE WINAPI
3658 DWORD Flags, 3633create_toolhelp32_snapshot (DWORD Flags, DWORD Ignored)
3659 DWORD Ignored)
3660{ 3634{
3661 static CreateToolhelp32Snapshot_Proc s_pfn_Create_Toolhelp32_Snapshot = NULL; 3635 static CreateToolhelp32Snapshot_Proc s_pfn_Create_Toolhelp32_Snapshot = NULL;
3662 3636
@@ -3674,9 +3648,8 @@ HANDLE WINAPI create_toolhelp32_snapshot (
3674 return (s_pfn_Create_Toolhelp32_Snapshot (Flags, Ignored)); 3648 return (s_pfn_Create_Toolhelp32_Snapshot (Flags, Ignored));
3675} 3649}
3676 3650
3677BOOL WINAPI process32_first ( 3651static BOOL WINAPI
3678 HANDLE hSnapshot, 3652process32_first (HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
3679 LPPROCESSENTRY32 lppe)
3680{ 3653{
3681 static Process32First_Proc s_pfn_Process32_First = NULL; 3654 static Process32First_Proc s_pfn_Process32_First = NULL;
3682 3655
@@ -3694,9 +3667,8 @@ BOOL WINAPI process32_first (
3694 return (s_pfn_Process32_First (hSnapshot, lppe)); 3667 return (s_pfn_Process32_First (hSnapshot, lppe));
3695} 3668}
3696 3669
3697BOOL WINAPI process32_next ( 3670static BOOL WINAPI
3698 HANDLE hSnapshot, 3671process32_next (HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
3699 LPPROCESSENTRY32 lppe)
3700{ 3672{
3701 static Process32Next_Proc s_pfn_Process32_Next = NULL; 3673 static Process32Next_Proc s_pfn_Process32_Next = NULL;
3702 3674
@@ -3714,11 +3686,11 @@ BOOL WINAPI process32_next (
3714 return (s_pfn_Process32_Next (hSnapshot, lppe)); 3686 return (s_pfn_Process32_Next (hSnapshot, lppe));
3715} 3687}
3716 3688
3717BOOL WINAPI open_thread_token ( 3689static BOOL WINAPI
3718 HANDLE ThreadHandle, 3690open_thread_token (HANDLE ThreadHandle,
3719 DWORD DesiredAccess, 3691 DWORD DesiredAccess,
3720 BOOL OpenAsSelf, 3692 BOOL OpenAsSelf,
3721 PHANDLE TokenHandle) 3693 PHANDLE TokenHandle)
3722{ 3694{
3723 static OpenThreadToken_Proc s_pfn_Open_Thread_Token = NULL; 3695 static OpenThreadToken_Proc s_pfn_Open_Thread_Token = NULL;
3724 HMODULE hm_advapi32 = NULL; 3696 HMODULE hm_advapi32 = NULL;
@@ -3748,8 +3720,8 @@ BOOL WINAPI open_thread_token (
3748 ); 3720 );
3749} 3721}
3750 3722
3751BOOL WINAPI impersonate_self ( 3723static BOOL WINAPI
3752 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) 3724impersonate_self (SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
3753{ 3725{
3754 static ImpersonateSelf_Proc s_pfn_Impersonate_Self = NULL; 3726 static ImpersonateSelf_Proc s_pfn_Impersonate_Self = NULL;
3755 HMODULE hm_advapi32 = NULL; 3727 HMODULE hm_advapi32 = NULL;
@@ -3771,7 +3743,8 @@ BOOL WINAPI impersonate_self (
3771 return s_pfn_Impersonate_Self (ImpersonationLevel); 3743 return s_pfn_Impersonate_Self (ImpersonationLevel);
3772} 3744}
3773 3745
3774BOOL WINAPI revert_to_self (void) 3746static BOOL WINAPI
3747revert_to_self (void)
3775{ 3748{
3776 static RevertToSelf_Proc s_pfn_Revert_To_Self = NULL; 3749 static RevertToSelf_Proc s_pfn_Revert_To_Self = NULL;
3777 HMODULE hm_advapi32 = NULL; 3750 HMODULE hm_advapi32 = NULL;
@@ -3793,10 +3766,10 @@ BOOL WINAPI revert_to_self (void)
3793 return s_pfn_Revert_To_Self (); 3766 return s_pfn_Revert_To_Self ();
3794} 3767}
3795 3768
3796BOOL WINAPI get_process_memory_info ( 3769static BOOL WINAPI
3797 HANDLE h_proc, 3770get_process_memory_info (HANDLE h_proc,
3798 PPROCESS_MEMORY_COUNTERS mem_counters, 3771 PPROCESS_MEMORY_COUNTERS mem_counters,
3799 DWORD bufsize) 3772 DWORD bufsize)
3800{ 3773{
3801 static GetProcessMemoryInfo_Proc s_pfn_Get_Process_Memory_Info = NULL; 3774 static GetProcessMemoryInfo_Proc s_pfn_Get_Process_Memory_Info = NULL;
3802 HMODULE hm_psapi = NULL; 3775 HMODULE hm_psapi = NULL;
@@ -3819,10 +3792,10 @@ BOOL WINAPI get_process_memory_info (
3819 return s_pfn_Get_Process_Memory_Info (h_proc, mem_counters, bufsize); 3792 return s_pfn_Get_Process_Memory_Info (h_proc, mem_counters, bufsize);
3820} 3793}
3821 3794
3822BOOL WINAPI get_process_working_set_size ( 3795static BOOL WINAPI
3823 HANDLE h_proc, 3796get_process_working_set_size (HANDLE h_proc,
3824 DWORD *minrss, 3797 DWORD *minrss,
3825 DWORD *maxrss) 3798 DWORD *maxrss)
3826{ 3799{
3827 static GetProcessWorkingSetSize_Proc 3800 static GetProcessWorkingSetSize_Proc
3828 s_pfn_Get_Process_Working_Set_Size = NULL; 3801 s_pfn_Get_Process_Working_Set_Size = NULL;
@@ -3845,8 +3818,8 @@ BOOL WINAPI get_process_working_set_size (
3845 return s_pfn_Get_Process_Working_Set_Size (h_proc, minrss, maxrss); 3818 return s_pfn_Get_Process_Working_Set_Size (h_proc, minrss, maxrss);
3846} 3819}
3847 3820
3848BOOL WINAPI global_memory_status ( 3821static BOOL WINAPI
3849 MEMORYSTATUS *buf) 3822global_memory_status (MEMORYSTATUS *buf)
3850{ 3823{
3851 static GlobalMemoryStatus_Proc s_pfn_Global_Memory_Status = NULL; 3824 static GlobalMemoryStatus_Proc s_pfn_Global_Memory_Status = NULL;
3852 3825
@@ -3868,8 +3841,8 @@ BOOL WINAPI global_memory_status (
3868 return s_pfn_Global_Memory_Status (buf); 3841 return s_pfn_Global_Memory_Status (buf);
3869} 3842}
3870 3843
3871BOOL WINAPI global_memory_status_ex ( 3844static BOOL WINAPI
3872 MEMORY_STATUS_EX *buf) 3845global_memory_status_ex (MEMORY_STATUS_EX *buf)
3873{ 3846{
3874 static GlobalMemoryStatusEx_Proc s_pfn_Global_Memory_Status_Ex = NULL; 3847 static GlobalMemoryStatusEx_Proc s_pfn_Global_Memory_Status_Ex = NULL;
3875 3848
@@ -4348,8 +4321,6 @@ system_process_attributes (Lisp_Object pid)
4348} 4321}
4349 4322
4350 4323
4351#ifdef HAVE_SOCKETS
4352
4353/* Wrappers for winsock functions to map between our file descriptors 4324/* Wrappers for winsock functions to map between our file descriptors
4354 and winsock's handles; also set h_errno for convenience. 4325 and winsock's handles; also set h_errno for convenience.
4355 4326
@@ -4429,7 +4400,6 @@ init_winsock (int load_now)
4429 if (winsock_lib != NULL) 4400 if (winsock_lib != NULL)
4430 return TRUE; 4401 return TRUE;
4431 4402
4432 pfn_SetHandleInformation = NULL;
4433 pfn_SetHandleInformation 4403 pfn_SetHandleInformation
4434 = (void *) GetProcAddress (GetModuleHandle ("kernel32.dll"), 4404 = (void *) GetProcAddress (GetModuleHandle ("kernel32.dll"),
4435 "SetHandleInformation"); 4405 "SetHandleInformation");
@@ -4636,15 +4606,9 @@ sys_strerror (int error_no)
4636 but I believe the method of keeping the socket handle separate (and 4606 but I believe the method of keeping the socket handle separate (and
4637 insuring it is not inheritable) is the correct one. */ 4607 insuring it is not inheritable) is the correct one. */
4638 4608
4639//#define SOCK_REPLACE_HANDLE
4640
4641#ifdef SOCK_REPLACE_HANDLE
4642#define SOCK_HANDLE(fd) ((SOCKET) _get_osfhandle (fd))
4643#else
4644#define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd) 4609#define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd)
4645#endif
4646 4610
4647int socket_to_fd (SOCKET s); 4611static int socket_to_fd (SOCKET s);
4648 4612
4649int 4613int
4650sys_socket (int af, int type, int protocol) 4614sys_socket (int af, int type, int protocol)
@@ -4670,7 +4634,7 @@ sys_socket (int af, int type, int protocol)
4670} 4634}
4671 4635
4672/* Convert a SOCKET to a file descriptor. */ 4636/* Convert a SOCKET to a file descriptor. */
4673int 4637static int
4674socket_to_fd (SOCKET s) 4638socket_to_fd (SOCKET s)
4675{ 4639{
4676 int fd; 4640 int fd;
@@ -4686,13 +4650,6 @@ socket_to_fd (SOCKET s)
4686 fd = _open ("NUL:", _O_RDWR); 4650 fd = _open ("NUL:", _O_RDWR);
4687 if (fd >= 0) 4651 if (fd >= 0)
4688 { 4652 {
4689#ifdef SOCK_REPLACE_HANDLE
4690 /* now replace handle to NUL with our socket handle */
4691 CloseHandle ((HANDLE) _get_osfhandle (fd));
4692 _free_osfhnd (fd);
4693 _set_osfhnd (fd, s);
4694 /* setmode (fd, _O_BINARY); */
4695#else
4696 /* Make a non-inheritable copy of the socket handle. Note 4653 /* Make a non-inheritable copy of the socket handle. Note
4697 that it is possible that sockets aren't actually kernel 4654 that it is possible that sockets aren't actually kernel
4698 handles, which appears to be the case on Windows 9x when 4655 handles, which appears to be the case on Windows 9x when
@@ -4738,7 +4695,6 @@ socket_to_fd (SOCKET s)
4738 } 4695 }
4739 } 4696 }
4740 fd_info[fd].hnd = (HANDLE) s; 4697 fd_info[fd].hnd = (HANDLE) s;
4741#endif
4742 4698
4743 /* set our own internal flags */ 4699 /* set our own internal flags */
4744 fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE; 4700 fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE;
@@ -4771,7 +4727,6 @@ socket_to_fd (SOCKET s)
4771 return -1; 4727 return -1;
4772} 4728}
4773 4729
4774
4775int 4730int
4776sys_bind (int s, const struct sockaddr * addr, int namelen) 4731sys_bind (int s, const struct sockaddr * addr, int namelen)
4777{ 4732{
@@ -4793,7 +4748,6 @@ sys_bind (int s, const struct sockaddr * addr, int namelen)
4793 return SOCKET_ERROR; 4748 return SOCKET_ERROR;
4794} 4749}
4795 4750
4796
4797int 4751int
4798sys_connect (int s, const struct sockaddr * name, int namelen) 4752sys_connect (int s, const struct sockaddr * name, int namelen)
4799{ 4753{
@@ -4906,7 +4860,6 @@ sys_getpeername (int s, struct sockaddr *addr, int * namelen)
4906 return SOCKET_ERROR; 4860 return SOCKET_ERROR;
4907} 4861}
4908 4862
4909
4910int 4863int
4911sys_shutdown (int s, int how) 4864sys_shutdown (int s, int how)
4912{ 4865{
@@ -5099,8 +5052,6 @@ fcntl (int s, int cmd, int options)
5099 return SOCKET_ERROR; 5052 return SOCKET_ERROR;
5100} 5053}
5101 5054
5102#endif /* HAVE_SOCKETS */
5103
5104 5055
5105/* Shadow main io functions: we need to handle pipes and sockets more 5056/* Shadow main io functions: we need to handle pipes and sockets more
5106 intelligently, and implement non-blocking mode as well. */ 5057 intelligently, and implement non-blocking mode as well. */
@@ -5135,18 +5086,15 @@ sys_close (int fd)
5135 } 5086 }
5136 if (i == MAXDESC) 5087 if (i == MAXDESC)
5137 { 5088 {
5138#ifdef HAVE_SOCKETS
5139 if (fd_info[fd].flags & FILE_SOCKET) 5089 if (fd_info[fd].flags & FILE_SOCKET)
5140 { 5090 {
5141#ifndef SOCK_REPLACE_HANDLE
5142 if (winsock_lib == NULL) abort (); 5091 if (winsock_lib == NULL) abort ();
5143 5092
5144 pfn_shutdown (SOCK_HANDLE (fd), 2); 5093 pfn_shutdown (SOCK_HANDLE (fd), 2);
5145 rc = pfn_closesocket (SOCK_HANDLE (fd)); 5094 rc = pfn_closesocket (SOCK_HANDLE (fd));
5146#endif 5095
5147 winsock_inuse--; /* count open sockets */ 5096 winsock_inuse--; /* count open sockets */
5148 } 5097 }
5149#endif
5150 delete_child (cp); 5098 delete_child (cp);
5151 } 5099 }
5152 } 5100 }
@@ -5178,7 +5126,6 @@ sys_dup (int fd)
5178 return new_fd; 5126 return new_fd;
5179} 5127}
5180 5128
5181
5182int 5129int
5183sys_dup2 (int src, int dst) 5130sys_dup2 (int src, int dst)
5184{ 5131{
@@ -5314,7 +5261,6 @@ _sys_read_ahead (int fd)
5314 return STATUS_READ_ERROR; 5261 return STATUS_READ_ERROR;
5315 } 5262 }
5316 } 5263 }
5317#ifdef HAVE_SOCKETS
5318 else if (fd_info[fd].flags & FILE_SOCKET) 5264 else if (fd_info[fd].flags & FILE_SOCKET)
5319 { 5265 {
5320 unsigned long nblock = 0; 5266 unsigned long nblock = 0;
@@ -5330,7 +5276,6 @@ _sys_read_ahead (int fd)
5330 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); 5276 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock);
5331 } 5277 }
5332 } 5278 }
5333#endif
5334 5279
5335 if (rc == sizeof (char)) 5280 if (rc == sizeof (char))
5336 cp->status = STATUS_READ_SUCCEEDED; 5281 cp->status = STATUS_READ_SUCCEEDED;
@@ -5502,7 +5447,6 @@ sys_read (int fd, char * buffer, unsigned int count)
5502 nchars += rc; 5447 nchars += rc;
5503 } 5448 }
5504 } 5449 }
5505#ifdef HAVE_SOCKETS
5506 else /* FILE_SOCKET */ 5450 else /* FILE_SOCKET */
5507 { 5451 {
5508 if (winsock_lib == NULL) abort (); 5452 if (winsock_lib == NULL) abort ();
@@ -5529,7 +5473,6 @@ sys_read (int fd, char * buffer, unsigned int count)
5529 nchars += res; 5473 nchars += res;
5530 } 5474 }
5531 } 5475 }
5532#endif
5533 } 5476 }
5534 else 5477 else
5535 { 5478 {
@@ -5654,9 +5597,7 @@ sys_write (int fd, const void * buffer, unsigned int count)
5654 } 5597 }
5655 } 5598 }
5656 } 5599 }
5657 else 5600 else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
5658#ifdef HAVE_SOCKETS
5659 if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
5660 { 5601 {
5661 unsigned long nblock = 0; 5602 unsigned long nblock = 0;
5662 if (winsock_lib == NULL) abort (); 5603 if (winsock_lib == NULL) abort ();
@@ -5684,7 +5625,6 @@ sys_write (int fd, const void * buffer, unsigned int count)
5684 } 5625 }
5685 } 5626 }
5686 else 5627 else
5687#endif
5688 { 5628 {
5689 /* Some networked filesystems don't like too large writes, so 5629 /* Some networked filesystems don't like too large writes, so
5690 break them into smaller chunks. See the Comments section of 5630 break them into smaller chunks. See the Comments section of
@@ -5776,10 +5716,8 @@ check_windows_init_file (void)
5776void 5716void
5777term_ntproc (void) 5717term_ntproc (void)
5778{ 5718{
5779#ifdef HAVE_SOCKETS
5780 /* shutdown the socket interface if necessary */ 5719 /* shutdown the socket interface if necessary */
5781 term_winsock (); 5720 term_winsock ();
5782#endif
5783 5721
5784 term_w32select (); 5722 term_w32select ();
5785} 5723}
@@ -5787,7 +5725,6 @@ term_ntproc (void)
5787void 5725void
5788init_ntproc (void) 5726init_ntproc (void)
5789{ 5727{
5790#ifdef HAVE_SOCKETS
5791 /* Initialise the socket interface now if available and requested by 5728 /* Initialise the socket interface now if available and requested by
5792 the user by defining PRELOAD_WINSOCK; otherwise loading will be 5729 the user by defining PRELOAD_WINSOCK; otherwise loading will be
5793 delayed until open-network-stream is called (w32-has-winsock can 5730 delayed until open-network-stream is called (w32-has-winsock can
@@ -5801,7 +5738,6 @@ init_ntproc (void)
5801 5738
5802 if (getenv ("PRELOAD_WINSOCK") != NULL) 5739 if (getenv ("PRELOAD_WINSOCK") != NULL)
5803 init_winsock (TRUE); 5740 init_winsock (TRUE);
5804#endif
5805 5741
5806 /* Initial preparation for subprocess support: replace our standard 5742 /* Initial preparation for subprocess support: replace our standard
5807 handles with non-inheritable versions. */ 5743 handles with non-inheritable versions. */
@@ -5893,7 +5829,7 @@ init_ntproc (void)
5893 shutdown_handler ensures that buffers' autosave files are 5829 shutdown_handler ensures that buffers' autosave files are
5894 up to date when the user logs off, or the system shuts down. 5830 up to date when the user logs off, or the system shuts down.
5895*/ 5831*/
5896BOOL WINAPI 5832static BOOL WINAPI
5897shutdown_handler (DWORD type) 5833shutdown_handler (DWORD type)
5898{ 5834{
5899 /* Ctrl-C and Ctrl-Break are already suppressed, so don't handle them. */ 5835 /* Ctrl-C and Ctrl-Break are already suppressed, so don't handle them. */
@@ -5926,7 +5862,6 @@ globals_of_w32 (void)
5926 g_b_init_open_process_token = 0; 5862 g_b_init_open_process_token = 0;
5927 g_b_init_get_token_information = 0; 5863 g_b_init_get_token_information = 0;
5928 g_b_init_lookup_account_sid = 0; 5864 g_b_init_lookup_account_sid = 0;
5929 g_b_init_get_sid_identifier_authority = 0;
5930 g_b_init_get_sid_sub_authority = 0; 5865 g_b_init_get_sid_sub_authority = 0;
5931 g_b_init_get_sid_sub_authority_count = 0; 5866 g_b_init_get_sid_sub_authority_count = 0;
5932 g_b_init_get_file_security = 0; 5867 g_b_init_get_file_security = 0;
diff --git a/src/w32fns.c b/src/w32fns.c
index f91ad948828..5e5f11c813d 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -262,7 +262,6 @@ typedef BOOL (WINAPI * GetMonitorInfo_Proc)
262 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info); 262 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
263 263
264TrackMouseEvent_Proc track_mouse_event_fn = NULL; 264TrackMouseEvent_Proc track_mouse_event_fn = NULL;
265ClipboardSequence_Proc clipboard_sequence_fn = NULL;
266ImmGetCompositionString_Proc get_composition_string_fn = NULL; 265ImmGetCompositionString_Proc get_composition_string_fn = NULL;
267ImmGetContext_Proc get_ime_context_fn = NULL; 266ImmGetContext_Proc get_ime_context_fn = NULL;
268ImmReleaseContext_Proc release_ime_context_fn = NULL; 267ImmReleaseContext_Proc release_ime_context_fn = NULL;
@@ -7183,9 +7182,6 @@ globals_of_w32fns (void)
7183 */ 7182 */
7184 track_mouse_event_fn = (TrackMouseEvent_Proc) 7183 track_mouse_event_fn = (TrackMouseEvent_Proc)
7185 GetProcAddress (user32_lib, "TrackMouseEvent"); 7184 GetProcAddress (user32_lib, "TrackMouseEvent");
7186 /* ditto for GetClipboardSequenceNumber. */
7187 clipboard_sequence_fn = (ClipboardSequence_Proc)
7188 GetProcAddress (user32_lib, "GetClipboardSequenceNumber");
7189 7185
7190 monitor_from_point_fn = (MonitorFromPoint_Proc) 7186 monitor_from_point_fn = (MonitorFromPoint_Proc)
7191 GetProcAddress (user32_lib, "MonitorFromPoint"); 7187 GetProcAddress (user32_lib, "MonitorFromPoint");
diff --git a/src/w32proc.c b/src/w32proc.c
index af923723709..ae4e725b6ef 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1694,8 +1694,6 @@ set_process_dir (char * dir)
1694 process_dir = dir; 1694 process_dir = dir;
1695} 1695}
1696 1696
1697#ifdef HAVE_SOCKETS
1698
1699/* To avoid problems with winsock implementations that work over dial-up 1697/* To avoid problems with winsock implementations that work over dial-up
1700 connections causing or requiring a connection to exist while Emacs is 1698 connections causing or requiring a connection to exist while Emacs is
1701 running, Emacs no longer automatically loads winsock on startup if it 1699 running, Emacs no longer automatically loads winsock on startup if it
@@ -1759,8 +1757,6 @@ socket connections still exist. */)
1759 return term_winsock () ? Qt : Qnil; 1757 return term_winsock () ? Qt : Qnil;
1760} 1758}
1761 1759
1762#endif /* HAVE_SOCKETS */
1763
1764 1760
1765/* Some miscellaneous functions that are Windows specific, but not GUI 1761/* Some miscellaneous functions that are Windows specific, but not GUI
1766 specific (ie. are applicable in terminal or batch mode as well). */ 1762 specific (ie. are applicable in terminal or batch mode as well). */
@@ -2268,10 +2264,9 @@ syms_of_ntproc (void)
2268 DEFSYM (Qhigh, "high"); 2264 DEFSYM (Qhigh, "high");
2269 DEFSYM (Qlow, "low"); 2265 DEFSYM (Qlow, "low");
2270 2266
2271#ifdef HAVE_SOCKETS
2272 defsubr (&Sw32_has_winsock); 2267 defsubr (&Sw32_has_winsock);
2273 defsubr (&Sw32_unload_winsock); 2268 defsubr (&Sw32_unload_winsock);
2274#endif 2269
2275 defsubr (&Sw32_short_file_name); 2270 defsubr (&Sw32_short_file_name);
2276 defsubr (&Sw32_long_file_name); 2271 defsubr (&Sw32_long_file_name);
2277 defsubr (&Sw32_set_process_priority); 2272 defsubr (&Sw32_set_process_priority);
diff --git a/src/window.c b/src/window.c
index 1fabe72d72d..7591401ee42 100644
--- a/src/window.c
+++ b/src/window.c
@@ -311,7 +311,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
311 (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) 311 (Lisp_Object pos, Lisp_Object window, Lisp_Object partially)
312{ 312{
313 register struct window *w; 313 register struct window *w;
314 register int posint; 314 register EMACS_INT posint;
315 register struct buffer *buf; 315 register struct buffer *buf;
316 struct text_pos top; 316 struct text_pos top;
317 Lisp_Object in_window = Qnil; 317 Lisp_Object in_window = Qnil;
@@ -2500,7 +2500,7 @@ window-start value is reasonable when this function is called. */)
2500 (Lisp_Object window) 2500 (Lisp_Object window)
2501{ 2501{
2502 struct window *w; 2502 struct window *w;
2503 int startpos; 2503 EMACS_INT startpos;
2504 int top, new_top; 2504 int top, new_top;
2505 2505
2506 if (NILP (window)) 2506 if (NILP (window))
@@ -3629,7 +3629,7 @@ selected window before each command. */)
3629 redisplay_window has altered point after scrolling, 3629 redisplay_window has altered point after scrolling,
3630 because it makes the change only in the window. */ 3630 because it makes the change only in the window. */
3631 { 3631 {
3632 register int new_point = marker_position (w->pointm); 3632 register EMACS_INT new_point = marker_position (w->pointm);
3633 if (new_point < BEGV) 3633 if (new_point < BEGV)
3634 SET_PT (BEGV); 3634 SET_PT (BEGV);
3635 else if (new_point > ZV) 3635 else if (new_point > ZV)
@@ -4848,7 +4848,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4848 /* Maybe modify window start instead of scrolling. */ 4848 /* Maybe modify window start instead of scrolling. */
4849 if (rbot > 0 || w->vscroll < 0) 4849 if (rbot > 0 || w->vscroll < 0)
4850 { 4850 {
4851 int spos; 4851 EMACS_INT spos;
4852 4852
4853 Fset_window_vscroll (window, make_number (0), Qt); 4853 Fset_window_vscroll (window, make_number (0), Qt);
4854 /* If there are other text lines above the current row, 4854 /* If there are other text lines above the current row,
@@ -4902,7 +4902,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4902 start_display (&it, w, start); 4902 start_display (&it, w, start);
4903 if (whole) 4903 if (whole)
4904 { 4904 {
4905 int start_pos = IT_CHARPOS (it); 4905 EMACS_INT start_pos = IT_CHARPOS (it);
4906 int dy = WINDOW_FRAME_LINE_HEIGHT (w); 4906 int dy = WINDOW_FRAME_LINE_HEIGHT (w);
4907 dy = max ((window_box_height (w) 4907 dy = max ((window_box_height (w)
4908 - next_screen_context_lines * dy), 4908 - next_screen_context_lines * dy),
@@ -4981,8 +4981,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4981 4981
4982 if (! vscrolled) 4982 if (! vscrolled)
4983 { 4983 {
4984 int pos = IT_CHARPOS (it); 4984 EMACS_INT pos = IT_CHARPOS (it);
4985 int bytepos; 4985 EMACS_INT bytepos;
4986 4986
4987 /* If in the middle of a multi-glyph character move forward to 4987 /* If in the middle of a multi-glyph character move forward to
4988 the next character. */ 4988 the next character. */
@@ -5052,7 +5052,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
5052 } 5052 }
5053 else if (n < 0) 5053 else if (n < 0)
5054 { 5054 {
5055 int charpos, bytepos; 5055 EMACS_INT charpos, bytepos;
5056 int partial_p; 5056 int partial_p;
5057 5057
5058 /* Save our position, for the 5058 /* Save our position, for the
@@ -5122,13 +5122,13 @@ static void
5122window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) 5122window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
5123{ 5123{
5124 register struct window *w = XWINDOW (window); 5124 register struct window *w = XWINDOW (window);
5125 register int opoint = PT, opoint_byte = PT_BYTE; 5125 register EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
5126 register int pos, pos_byte; 5126 register EMACS_INT pos, pos_byte;
5127 register int ht = window_internal_height (w); 5127 register int ht = window_internal_height (w);
5128 register Lisp_Object tem; 5128 register Lisp_Object tem;
5129 int lose; 5129 int lose;
5130 Lisp_Object bolp; 5130 Lisp_Object bolp;
5131 int startpos; 5131 EMACS_INT startpos;
5132 Lisp_Object original_pos = Qnil; 5132 Lisp_Object original_pos = Qnil;
5133 5133
5134 /* If scrolling screen-fulls, compute the number of lines to 5134 /* If scrolling screen-fulls, compute the number of lines to
@@ -5573,7 +5573,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5573 struct buffer *buf = XBUFFER (w->buffer); 5573 struct buffer *buf = XBUFFER (w->buffer);
5574 struct buffer *obuf = current_buffer; 5574 struct buffer *obuf = current_buffer;
5575 int center_p = 0; 5575 int center_p = 0;
5576 int charpos, bytepos; 5576 EMACS_INT charpos, bytepos;
5577 int iarg; 5577 int iarg;
5578 int this_scroll_margin; 5578 int this_scroll_margin;
5579 5579
@@ -5914,7 +5914,7 @@ the return value is nil. Otherwise the value is t. */)
5914 Lisp_Object new_current_buffer; 5914 Lisp_Object new_current_buffer;
5915 Lisp_Object frame; 5915 Lisp_Object frame;
5916 FRAME_PTR f; 5916 FRAME_PTR f;
5917 int old_point = -1; 5917 EMACS_INT old_point = -1;
5918 5918
5919 CHECK_WINDOW_CONFIGURATION (configuration); 5919 CHECK_WINDOW_CONFIGURATION (configuration);
5920 5920
diff --git a/src/xdisp.c b/src/xdisp.c
index 2ec271cdb6b..9b0f94ef657 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -907,7 +907,7 @@ Lisp_Object Qinhibit_free_realized_faces;
907Lisp_Object help_echo_string; 907Lisp_Object help_echo_string;
908Lisp_Object help_echo_window; 908Lisp_Object help_echo_window;
909Lisp_Object help_echo_object; 909Lisp_Object help_echo_object;
910int help_echo_pos; 910EMACS_INT help_echo_pos;
911 911
912/* Temporary variable for XTread_socket. */ 912/* Temporary variable for XTread_socket. */
913 913
@@ -956,7 +956,8 @@ static void pint2hrstr (char *, int, int);
956static struct text_pos run_window_scroll_functions (Lisp_Object, 956static struct text_pos run_window_scroll_functions (Lisp_Object,
957 struct text_pos); 957 struct text_pos);
958static void reconsider_clip_changes (struct window *, struct buffer *); 958static void reconsider_clip_changes (struct window *, struct buffer *);
959static int text_outside_line_unchanged_p (struct window *, int, int); 959static int text_outside_line_unchanged_p (struct window *,
960 EMACS_INT, EMACS_INT);
960static void store_mode_line_noprop_char (char); 961static void store_mode_line_noprop_char (char);
961static int store_mode_line_noprop (const unsigned char *, int, int); 962static int store_mode_line_noprop (const unsigned char *, int, int);
962static void x_consider_frame_title (Lisp_Object); 963static void x_consider_frame_title (Lisp_Object);
@@ -991,8 +992,9 @@ static int append_space_for_newline (struct it *, int);
991static int cursor_row_fully_visible_p (struct window *, int, int); 992static int cursor_row_fully_visible_p (struct window *, int, int);
992static int try_scrolling (Lisp_Object, int, EMACS_INT, EMACS_INT, int, int); 993static int try_scrolling (Lisp_Object, int, EMACS_INT, EMACS_INT, int, int);
993static int try_cursor_movement (Lisp_Object, struct text_pos, int *); 994static int try_cursor_movement (Lisp_Object, struct text_pos, int *);
994static int trailing_whitespace_p (int); 995static int trailing_whitespace_p (EMACS_INT);
995static int message_log_check_duplicate (int, int, int, int); 996static int message_log_check_duplicate (EMACS_INT, EMACS_INT,
997 EMACS_INT, EMACS_INT);
996static void push_it (struct it *); 998static void push_it (struct it *);
997static void pop_it (struct it *); 999static void pop_it (struct it *);
998static void sync_frame_with_window_matrix_rows (struct window *); 1000static void sync_frame_with_window_matrix_rows (struct window *);
@@ -1015,13 +1017,14 @@ static int store_mode_line_string (const char *, Lisp_Object, int, int, int, Lis
1015static const char *decode_mode_spec (struct window *, int, int, int, 1017static const char *decode_mode_spec (struct window *, int, int, int,
1016 Lisp_Object *); 1018 Lisp_Object *);
1017static void display_menu_bar (struct window *); 1019static void display_menu_bar (struct window *);
1018static int display_count_lines (int, int, int, int, int *); 1020static int display_count_lines (EMACS_INT, EMACS_INT, EMACS_INT, int,
1021 EMACS_INT *);
1019static int display_string (const unsigned char *, Lisp_Object, Lisp_Object, 1022static int display_string (const unsigned char *, Lisp_Object, Lisp_Object,
1020 EMACS_INT, EMACS_INT, struct it *, int, int, int, int); 1023 EMACS_INT, EMACS_INT, struct it *, int, int, int, int);
1021static void compute_line_metrics (struct it *); 1024static void compute_line_metrics (struct it *);
1022static void run_redisplay_end_trigger_hook (struct it *); 1025static void run_redisplay_end_trigger_hook (struct it *);
1023static int get_overlay_strings (struct it *, int); 1026static int get_overlay_strings (struct it *, EMACS_INT);
1024static int get_overlay_strings_1 (struct it *, int, int); 1027static int get_overlay_strings_1 (struct it *, EMACS_INT, int);
1025static void next_overlay_string (struct it *); 1028static void next_overlay_string (struct it *);
1026static void reseat (struct it *, struct text_pos, int); 1029static void reseat (struct it *, struct text_pos, int);
1027static void reseat_1 (struct it *, struct text_pos, int); 1030static void reseat_1 (struct it *, struct text_pos, int);
@@ -1036,11 +1039,11 @@ static int next_element_from_buffer (struct it *);
1036static int next_element_from_composition (struct it *); 1039static int next_element_from_composition (struct it *);
1037static int next_element_from_image (struct it *); 1040static int next_element_from_image (struct it *);
1038static int next_element_from_stretch (struct it *); 1041static int next_element_from_stretch (struct it *);
1039static void load_overlay_strings (struct it *, int); 1042static void load_overlay_strings (struct it *, EMACS_INT);
1040static int init_from_display_pos (struct it *, struct window *, 1043static int init_from_display_pos (struct it *, struct window *,
1041 struct display_pos *); 1044 struct display_pos *);
1042static void reseat_to_string (struct it *, const unsigned char *, 1045static void reseat_to_string (struct it *, const unsigned char *,
1043 Lisp_Object, int, int, int, int); 1046 Lisp_Object, EMACS_INT, EMACS_INT, int, int);
1044static enum move_it_result 1047static enum move_it_result
1045 move_it_in_display_line_to (struct it *, EMACS_INT, int, 1048 move_it_in_display_line_to (struct it *, EMACS_INT, int,
1046 enum move_operation_enum); 1049 enum move_operation_enum);
@@ -1052,10 +1055,10 @@ static int init_to_row_end (struct it *, struct window *,
1052static void back_to_previous_line_start (struct it *); 1055static void back_to_previous_line_start (struct it *);
1053static int forward_to_next_line_start (struct it *, int *); 1056static int forward_to_next_line_start (struct it *, int *);
1054static struct text_pos string_pos_nchars_ahead (struct text_pos, 1057static struct text_pos string_pos_nchars_ahead (struct text_pos,
1055 Lisp_Object, int); 1058 Lisp_Object, EMACS_INT);
1056static struct text_pos string_pos (int, Lisp_Object); 1059static struct text_pos string_pos (EMACS_INT, Lisp_Object);
1057static struct text_pos c_string_pos (int, const unsigned char *, int); 1060static struct text_pos c_string_pos (EMACS_INT, const unsigned char *, int);
1058static int number_of_chars (const unsigned char *, int); 1061static EMACS_INT number_of_chars (const unsigned char *, int);
1059static void compute_stop_pos (struct it *); 1062static void compute_stop_pos (struct it *);
1060static void compute_string_pos (struct text_pos *, struct text_pos, 1063static void compute_string_pos (struct text_pos *, struct text_pos,
1061 Lisp_Object); 1064 Lisp_Object);
@@ -1362,7 +1365,7 @@ line_bottom_y (struct it *it)
1362 Set *ROWH and *VPOS to row's visible height and VPOS (row number). */ 1365 Set *ROWH and *VPOS to row's visible height and VPOS (row number). */
1363 1366
1364int 1367int
1365pos_visible_p (struct window *w, int charpos, int *x, int *y, 1368pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
1366 int *rtop, int *rbot, int *rowh, int *vpos) 1369 int *rtop, int *rbot, int *rowh, int *vpos)
1367{ 1370{
1368 struct it it; 1371 struct it it;
@@ -1522,13 +1525,13 @@ string_char_and_length (const unsigned char *str, int *len)
1522 in STRING, return the position NCHARS ahead (NCHARS >= 0). */ 1525 in STRING, return the position NCHARS ahead (NCHARS >= 0). */
1523 1526
1524static struct text_pos 1527static struct text_pos
1525string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, int nchars) 1528string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, EMACS_INT nchars)
1526{ 1529{
1527 xassert (STRINGP (string) && nchars >= 0); 1530 xassert (STRINGP (string) && nchars >= 0);
1528 1531
1529 if (STRING_MULTIBYTE (string)) 1532 if (STRING_MULTIBYTE (string))
1530 { 1533 {
1531 int rest = SBYTES (string) - BYTEPOS (pos); 1534 EMACS_INT rest = SBYTES (string) - BYTEPOS (pos);
1532 const unsigned char *p = SDATA (string) + BYTEPOS (pos); 1535 const unsigned char *p = SDATA (string) + BYTEPOS (pos);
1533 int len; 1536 int len;
1534 1537
@@ -1552,7 +1555,7 @@ string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, int nchars)
1552 for character position CHARPOS in STRING. */ 1555 for character position CHARPOS in STRING. */
1553 1556
1554static INLINE struct text_pos 1557static INLINE struct text_pos
1555string_pos (int charpos, Lisp_Object string) 1558string_pos (EMACS_INT charpos, Lisp_Object string)
1556{ 1559{
1557 struct text_pos pos; 1560 struct text_pos pos;
1558 xassert (STRINGP (string)); 1561 xassert (STRINGP (string));
@@ -1567,7 +1570,7 @@ string_pos (int charpos, Lisp_Object string)
1567 means recognize multibyte characters. */ 1570 means recognize multibyte characters. */
1568 1571
1569static struct text_pos 1572static struct text_pos
1570c_string_pos (int charpos, const unsigned char *s, int multibyte_p) 1573c_string_pos (EMACS_INT charpos, const unsigned char *s, int multibyte_p)
1571{ 1574{
1572 struct text_pos pos; 1575 struct text_pos pos;
1573 1576
@@ -1576,7 +1579,8 @@ c_string_pos (int charpos, const unsigned char *s, int multibyte_p)
1576 1579
1577 if (multibyte_p) 1580 if (multibyte_p)
1578 { 1581 {
1579 int rest = strlen (s), len; 1582 EMACS_INT rest = strlen (s);
1583 int len;
1580 1584
1581 SET_TEXT_POS (pos, 0, 0); 1585 SET_TEXT_POS (pos, 0, 0);
1582 while (charpos--) 1586 while (charpos--)
@@ -1598,14 +1602,15 @@ c_string_pos (int charpos, const unsigned char *s, int multibyte_p)
1598/* Value is the number of characters in C string S. MULTIBYTE_P 1602/* Value is the number of characters in C string S. MULTIBYTE_P
1599 non-zero means recognize multibyte characters. */ 1603 non-zero means recognize multibyte characters. */
1600 1604
1601static int 1605static EMACS_INT
1602number_of_chars (const unsigned char *s, int multibyte_p) 1606number_of_chars (const unsigned char *s, int multibyte_p)
1603{ 1607{
1604 int nchars; 1608 EMACS_INT nchars;
1605 1609
1606 if (multibyte_p) 1610 if (multibyte_p)
1607 { 1611 {
1608 int rest = strlen (s), len; 1612 EMACS_INT rest = strlen (s);
1613 int len;
1609 unsigned char *p = (unsigned char *) s; 1614 unsigned char *p = (unsigned char *) s;
1610 1615
1611 for (nchars = 0; rest > 0; ++nchars) 1616 for (nchars = 0; rest > 0; ++nchars)
@@ -2653,7 +2658,7 @@ init_iterator (struct it *it, struct window *w,
2653 && WINDOWP (minibuf_selected_window) 2658 && WINDOWP (minibuf_selected_window)
2654 && w == XWINDOW (minibuf_selected_window)))) 2659 && w == XWINDOW (minibuf_selected_window))))
2655 { 2660 {
2656 int charpos = marker_position (current_buffer->mark); 2661 EMACS_INT charpos = marker_position (current_buffer->mark);
2657 it->region_beg_charpos = min (PT, charpos); 2662 it->region_beg_charpos = min (PT, charpos);
2658 it->region_end_charpos = max (PT, charpos); 2663 it->region_end_charpos = max (PT, charpos);
2659 } 2664 }
@@ -2899,7 +2904,7 @@ in_ellipses_for_invisible_text_p (struct display_pos *pos, struct window *w)
2899{ 2904{
2900 Lisp_Object prop, window; 2905 Lisp_Object prop, window;
2901 int ellipses_p = 0; 2906 int ellipses_p = 0;
2902 int charpos = CHARPOS (pos->pos); 2907 EMACS_INT charpos = CHARPOS (pos->pos);
2903 2908
2904 /* If POS specifies a position in a display vector, this might 2909 /* If POS specifies a position in a display vector, this might
2905 be for an ellipsis displayed for invisible text. We won't 2910 be for an ellipsis displayed for invisible text. We won't
@@ -3177,7 +3182,7 @@ compute_stop_pos (struct it *it)
3177{ 3182{
3178 register INTERVAL iv, next_iv; 3183 register INTERVAL iv, next_iv;
3179 Lisp_Object object, limit, position; 3184 Lisp_Object object, limit, position;
3180 EMACS_INT charpos, bytepos, stoppos; 3185 EMACS_INT charpos, bytepos;
3181 3186
3182 /* If nowhere else, stop at the end. */ 3187 /* If nowhere else, stop at the end. */
3183 it->stop_charpos = it->end_charpos; 3188 it->stop_charpos = it->end_charpos;
@@ -3267,12 +3272,15 @@ compute_stop_pos (struct it *it)
3267 } 3272 }
3268 } 3273 }
3269 3274
3270 if (it->bidi_p && it->bidi_it.scan_dir < 0) 3275 if (it->cmp_it.id < 0)
3271 stoppos = -1; 3276 {
3272 else 3277 EMACS_INT stoppos = it->end_charpos;
3273 stoppos = it->stop_charpos; 3278
3274 composition_compute_stop_pos (&it->cmp_it, charpos, bytepos, 3279 if (it->bidi_p && it->bidi_it.scan_dir < 0)
3275 stoppos, it->string); 3280 stoppos = -1;
3281 composition_compute_stop_pos (&it->cmp_it, charpos, bytepos,
3282 stoppos, it->string);
3283 }
3276 3284
3277 xassert (STRINGP (it->string) 3285 xassert (STRINGP (it->string)
3278 || (it->stop_charpos >= BEGV 3286 || (it->stop_charpos >= BEGV
@@ -3452,7 +3460,8 @@ handle_face_prop (struct it *it)
3452 } 3460 }
3453 else 3461 else
3454 { 3462 {
3455 int base_face_id, bufpos; 3463 int base_face_id;
3464 EMACS_INT bufpos;
3456 int i; 3465 int i;
3457 Lisp_Object from_overlay 3466 Lisp_Object from_overlay
3458 = (it->current.overlay_string_index >= 0 3467 = (it->current.overlay_string_index >= 0
@@ -3576,7 +3585,8 @@ face_before_or_after_it_pos (struct it *it, int before_p)
3576 3585
3577 if (STRINGP (it->string)) 3586 if (STRINGP (it->string))
3578 { 3587 {
3579 int bufpos, base_face_id; 3588 EMACS_INT bufpos;
3589 int base_face_id;
3580 3590
3581 /* No face change past the end of the string (for the case 3591 /* No face change past the end of the string (for the case
3582 we are padding with spaces). No face change before the 3592 we are padding with spaces). No face change before the
@@ -3619,7 +3629,6 @@ face_before_or_after_it_pos (struct it *it, int before_p)
3619 if (STRING_MULTIBYTE (it->string)) 3629 if (STRING_MULTIBYTE (it->string))
3620 { 3630 {
3621 const unsigned char *p = SDATA (it->string) + BYTEPOS (pos); 3631 const unsigned char *p = SDATA (it->string) + BYTEPOS (pos);
3622 int rest = SBYTES (it->string) - BYTEPOS (pos);
3623 int c, len; 3632 int c, len;
3624 struct face *face = FACE_FROM_ID (it->f, face_id); 3633 struct face *face = FACE_FROM_ID (it->f, face_id);
3625 3634
@@ -3821,7 +3830,8 @@ handle_invisible_prop (struct it *it)
3821 not have a chance to do it, if we are going to 3830 not have a chance to do it, if we are going to
3822 skip any text at the beginning, which resets the 3831 skip any text at the beginning, which resets the
3823 FIRST_ELT flag. */ 3832 FIRST_ELT flag. */
3824 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); 3833 bidi_paragraph_init (it->paragraph_embedding,
3834 &it->bidi_it, 1);
3825 } 3835 }
3826 do 3836 do
3827 { 3837 {
@@ -4636,7 +4646,6 @@ string_buffer_position_lim (struct window *w, Lisp_Object string,
4636EMACS_INT 4646EMACS_INT
4637string_buffer_position (struct window *w, Lisp_Object string, EMACS_INT around_charpos) 4647string_buffer_position (struct window *w, Lisp_Object string, EMACS_INT around_charpos)
4638{ 4648{
4639 Lisp_Object limit, prop, pos;
4640 const int MAX_DISTANCE = 1000; 4649 const int MAX_DISTANCE = 1000;
4641 EMACS_INT found = string_buffer_position_lim (w, string, around_charpos, 4650 EMACS_INT found = string_buffer_position_lim (w, string, around_charpos,
4642 around_charpos + MAX_DISTANCE, 4651 around_charpos + MAX_DISTANCE,
@@ -4867,11 +4876,11 @@ compare_overlay_entries (const void *e1, const void *e2)
4867 compare_overlay_entries. */ 4876 compare_overlay_entries. */
4868 4877
4869static void 4878static void
4870load_overlay_strings (struct it *it, int charpos) 4879load_overlay_strings (struct it *it, EMACS_INT charpos)
4871{ 4880{
4872 Lisp_Object overlay, window, str, invisible; 4881 Lisp_Object overlay, window, str, invisible;
4873 struct Lisp_Overlay *ov; 4882 struct Lisp_Overlay *ov;
4874 int start, end; 4883 EMACS_INT start, end;
4875 int size = 20; 4884 int size = 20;
4876 int n = 0, i, j, invis_p; 4885 int n = 0, i, j, invis_p;
4877 struct overlay_entry *entries 4886 struct overlay_entry *entries
@@ -5017,7 +5026,7 @@ load_overlay_strings (struct it *it, int charpos)
5017 least one overlay string was found. */ 5026 least one overlay string was found. */
5018 5027
5019static int 5028static int
5020get_overlay_strings_1 (struct it *it, int charpos, int compute_stop_p) 5029get_overlay_strings_1 (struct it *it, EMACS_INT charpos, int compute_stop_p)
5021{ 5030{
5022 /* Get the first OVERLAY_STRING_CHUNK_SIZE overlay strings to 5031 /* Get the first OVERLAY_STRING_CHUNK_SIZE overlay strings to
5023 process. This fills IT->overlay_strings with strings, and sets 5032 process. This fills IT->overlay_strings with strings, and sets
@@ -5068,7 +5077,7 @@ get_overlay_strings_1 (struct it *it, int charpos, int compute_stop_p)
5068} 5077}
5069 5078
5070static int 5079static int
5071get_overlay_strings (struct it *it, int charpos) 5080get_overlay_strings (struct it *it, EMACS_INT charpos)
5072{ 5081{
5073 it->string = Qnil; 5082 it->string = Qnil;
5074 it->method = GET_FROM_BUFFER; 5083 it->method = GET_FROM_BUFFER;
@@ -5143,7 +5152,7 @@ iterate_out_of_display_property (struct it *it)
5143 of a new paragraph, next_element_from_buffer may not have a 5152 of a new paragraph, next_element_from_buffer may not have a
5144 chance to do that. */ 5153 chance to do that. */
5145 if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV) 5154 if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV)
5146 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); 5155 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1);
5147 /* prev_stop can be zero, so check against BEGV as well. */ 5156 /* prev_stop can be zero, so check against BEGV as well. */
5148 while (it->bidi_it.charpos >= BEGV 5157 while (it->bidi_it.charpos >= BEGV
5149 && it->prev_stop <= it->bidi_it.charpos 5158 && it->prev_stop <= it->bidi_it.charpos
@@ -5314,8 +5323,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5314 short-cut. */ 5323 short-cut. */
5315 if (!newline_found_p) 5324 if (!newline_found_p)
5316 { 5325 {
5317 int start = IT_CHARPOS (*it); 5326 EMACS_INT start = IT_CHARPOS (*it);
5318 int limit = find_next_newline_no_quit (start, 1); 5327 EMACS_INT limit = find_next_newline_no_quit (start, 1);
5319 Lisp_Object pos; 5328 Lisp_Object pos;
5320 5329
5321 xassert (!STRINGP (it->string)); 5330 xassert (!STRINGP (it->string));
@@ -5386,7 +5395,7 @@ back_to_previous_visible_line_start (struct it *it)
5386 5395
5387 { 5396 {
5388 struct it it2; 5397 struct it it2;
5389 int pos; 5398 EMACS_INT pos;
5390 EMACS_INT beg, end; 5399 EMACS_INT beg, end;
5391 Lisp_Object val, overlay; 5400 Lisp_Object val, overlay;
5392 5401
@@ -5508,7 +5517,7 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5508static void 5517static void
5509reseat (struct it *it, struct text_pos pos, int force_p) 5518reseat (struct it *it, struct text_pos pos, int force_p)
5510{ 5519{
5511 int original_pos = IT_CHARPOS (*it); 5520 EMACS_INT original_pos = IT_CHARPOS (*it);
5512 5521
5513 reseat_1 (it, pos, 0); 5522 reseat_1 (it, pos, 0);
5514 5523
@@ -5575,7 +5584,10 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5575 it->string_from_display_prop_p = 0; 5584 it->string_from_display_prop_p = 0;
5576 it->face_before_selective_p = 0; 5585 it->face_before_selective_p = 0;
5577 if (it->bidi_p) 5586 if (it->bidi_p)
5578 it->bidi_it.first_elt = 1; 5587 {
5588 it->bidi_it.first_elt = 1;
5589 it->bidi_it.paragraph_dir = NEUTRAL_DIR;
5590 }
5579 5591
5580 if (set_stop_p) 5592 if (set_stop_p)
5581 { 5593 {
@@ -5605,7 +5617,8 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5605 5617
5606static void 5618static void
5607reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string, 5619reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string,
5608 int charpos, int precision, int field_width, int multibyte) 5620 EMACS_INT charpos, EMACS_INT precision, int field_width,
5621 int multibyte)
5609{ 5622{
5610 /* No region in strings. */ 5623 /* No region in strings. */
5611 it->region_beg_charpos = it->region_end_charpos = -1; 5624 it->region_beg_charpos = it->region_end_charpos = -1;
@@ -6008,9 +6021,9 @@ get_next_display_element (struct it *it)
6008 } 6021 }
6009 else 6022 else
6010 { 6023 {
6011 int pos = (it->s ? -1 6024 EMACS_INT pos = (it->s ? -1
6012 : STRINGP (it->string) ? IT_STRING_CHARPOS (*it) 6025 : STRINGP (it->string) ? IT_STRING_CHARPOS (*it)
6013 : IT_CHARPOS (*it)); 6026 : IT_CHARPOS (*it));
6014 6027
6015 it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display, pos, 6028 it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display, pos,
6016 it->string); 6029 it->string);
@@ -6125,7 +6138,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
6125 it->cmp_it.id = -1; 6138 it->cmp_it.id = -1;
6126 composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), 6139 composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it),
6127 IT_BYTEPOS (*it), 6140 IT_BYTEPOS (*it),
6128 it->stop_charpos, Qnil); 6141 it->end_charpos, Qnil);
6129 } 6142 }
6130 } 6143 }
6131 else if (! it->cmp_it.reversed_p) 6144 else if (! it->cmp_it.reversed_p)
@@ -6148,7 +6161,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
6148 { 6161 {
6149 /* No more grapheme clusters in this composition. 6162 /* No more grapheme clusters in this composition.
6150 Find the next stop position. */ 6163 Find the next stop position. */
6151 EMACS_INT stop = it->stop_charpos; 6164 EMACS_INT stop = it->end_charpos;
6152 if (it->bidi_it.scan_dir < 0) 6165 if (it->bidi_it.scan_dir < 0)
6153 /* Now we are scanning backward and don't know 6166 /* Now we are scanning backward and don't know
6154 where to stop. */ 6167 where to stop. */
@@ -6176,7 +6189,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
6176 { 6189 {
6177 /* No more grapheme clusters in this composition. 6190 /* No more grapheme clusters in this composition.
6178 Find the next stop position. */ 6191 Find the next stop position. */
6179 EMACS_INT stop = it->stop_charpos; 6192 EMACS_INT stop = it->end_charpos;
6180 if (it->bidi_it.scan_dir < 0) 6193 if (it->bidi_it.scan_dir < 0)
6181 /* Now we are scanning backward and don't know 6194 /* Now we are scanning backward and don't know
6182 where to stop. */ 6195 where to stop. */
@@ -6201,7 +6214,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
6201 /* If this is a new paragraph, determine its base 6214 /* If this is a new paragraph, determine its base
6202 direction (a.k.a. its base embedding level). */ 6215 direction (a.k.a. its base embedding level). */
6203 if (it->bidi_it.new_paragraph) 6216 if (it->bidi_it.new_paragraph)
6204 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); 6217 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 0);
6205 bidi_move_to_visually_next (&it->bidi_it); 6218 bidi_move_to_visually_next (&it->bidi_it);
6206 IT_BYTEPOS (*it) = it->bidi_it.bytepos; 6219 IT_BYTEPOS (*it) = it->bidi_it.bytepos;
6207 IT_CHARPOS (*it) = it->bidi_it.charpos; 6220 IT_CHARPOS (*it) = it->bidi_it.charpos;
@@ -6209,7 +6222,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
6209 { 6222 {
6210 /* As the scan direction was changed, we must 6223 /* As the scan direction was changed, we must
6211 re-compute the stop position for composition. */ 6224 re-compute the stop position for composition. */
6212 EMACS_INT stop = it->stop_charpos; 6225 EMACS_INT stop = it->end_charpos;
6213 if (it->bidi_it.scan_dir < 0) 6226 if (it->bidi_it.scan_dir < 0)
6214 stop = -1; 6227 stop = -1;
6215 composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), 6228 composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it),
@@ -6287,7 +6300,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
6287 composition_compute_stop_pos (&it->cmp_it, 6300 composition_compute_stop_pos (&it->cmp_it,
6288 IT_STRING_CHARPOS (*it), 6301 IT_STRING_CHARPOS (*it),
6289 IT_STRING_BYTEPOS (*it), 6302 IT_STRING_BYTEPOS (*it),
6290 it->stop_charpos, it->string); 6303 it->end_charpos, it->string);
6291 } 6304 }
6292 } 6305 }
6293 else 6306 else
@@ -6443,7 +6456,6 @@ next_element_from_string (struct it *it)
6443 } 6456 }
6444 else if (STRING_MULTIBYTE (it->string)) 6457 else if (STRING_MULTIBYTE (it->string))
6445 { 6458 {
6446 int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
6447 const unsigned char *s = (SDATA (it->string) 6459 const unsigned char *s = (SDATA (it->string)
6448 + IT_STRING_BYTEPOS (*it)); 6460 + IT_STRING_BYTEPOS (*it));
6449 it->c = string_char_and_length (s, &it->len); 6461 it->c = string_char_and_length (s, &it->len);
@@ -6479,7 +6491,6 @@ next_element_from_string (struct it *it)
6479 } 6491 }
6480 else if (STRING_MULTIBYTE (it->string)) 6492 else if (STRING_MULTIBYTE (it->string))
6481 { 6493 {
6482 int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
6483 const unsigned char *s = (SDATA (it->string) 6494 const unsigned char *s = (SDATA (it->string)
6484 + IT_STRING_BYTEPOS (*it)); 6495 + IT_STRING_BYTEPOS (*it));
6485 it->c = string_char_and_length (s, &it->len); 6496 it->c = string_char_and_length (s, &it->len);
@@ -6532,13 +6543,7 @@ next_element_from_c_string (struct it *it)
6532 BYTEPOS (it->position) = CHARPOS (it->position) = -1; 6543 BYTEPOS (it->position) = CHARPOS (it->position) = -1;
6533 } 6544 }
6534 else if (it->multibyte_p) 6545 else if (it->multibyte_p)
6535 { 6546 it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
6536 /* Implementation note: The calls to strlen apparently aren't a
6537 performance problem because there is no noticeable performance
6538 difference between Emacs running in unibyte or multibyte mode. */
6539 int maxlen = strlen (it->s) - IT_BYTEPOS (*it);
6540 it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
6541 }
6542 else 6547 else
6543 it->c = it->s[IT_BYTEPOS (*it)], it->len = 1; 6548 it->c = it->s[IT_BYTEPOS (*it)], it->len = 1;
6544 6549
@@ -6673,12 +6678,12 @@ next_element_from_buffer (struct it *it)
6673 { 6678 {
6674 /* If we are at the beginning of a line, we can produce the 6679 /* If we are at the beginning of a line, we can produce the
6675 next element right away. */ 6680 next element right away. */
6676 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); 6681 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1);
6677 bidi_move_to_visually_next (&it->bidi_it); 6682 bidi_move_to_visually_next (&it->bidi_it);
6678 } 6683 }
6679 else 6684 else
6680 { 6685 {
6681 int orig_bytepos = IT_BYTEPOS (*it); 6686 EMACS_INT orig_bytepos = IT_BYTEPOS (*it);
6682 6687
6683 /* We need to prime the bidi iterator starting at the line's 6688 /* We need to prime the bidi iterator starting at the line's
6684 beginning, before we will be able to produce the next 6689 beginning, before we will be able to produce the next
@@ -6687,7 +6692,7 @@ next_element_from_buffer (struct it *it)
6687 IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it)); 6692 IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it));
6688 it->bidi_it.charpos = IT_CHARPOS (*it); 6693 it->bidi_it.charpos = IT_CHARPOS (*it);
6689 it->bidi_it.bytepos = IT_BYTEPOS (*it); 6694 it->bidi_it.bytepos = IT_BYTEPOS (*it);
6690 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); 6695 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1);
6691 do 6696 do
6692 { 6697 {
6693 /* Now return to buffer position where we were asked to 6698 /* Now return to buffer position where we were asked to
@@ -6704,7 +6709,7 @@ next_element_from_buffer (struct it *it)
6704 IT_BYTEPOS (*it) = it->bidi_it.bytepos; 6709 IT_BYTEPOS (*it) = it->bidi_it.bytepos;
6705 SET_TEXT_POS (it->position, IT_CHARPOS (*it), IT_BYTEPOS (*it)); 6710 SET_TEXT_POS (it->position, IT_CHARPOS (*it), IT_BYTEPOS (*it));
6706 { 6711 {
6707 EMACS_INT stop = it->stop_charpos; 6712 EMACS_INT stop = it->end_charpos;
6708 if (it->bidi_it.scan_dir < 0) 6713 if (it->bidi_it.scan_dir < 0)
6709 stop = -1; 6714 stop = -1;
6710 composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), 6715 composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it),
@@ -6910,7 +6915,7 @@ next_element_from_composition (struct it *it)
6910 if (it->bidi_p) 6915 if (it->bidi_p)
6911 { 6916 {
6912 if (it->bidi_it.new_paragraph) 6917 if (it->bidi_it.new_paragraph)
6913 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); 6918 bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 0);
6914 /* Resync the bidi iterator with IT's new position. 6919 /* Resync the bidi iterator with IT's new position.
6915 FIXME: this doesn't support bidirectional text. */ 6920 FIXME: this doesn't support bidirectional text. */
6916 while (it->bidi_it.charpos < IT_CHARPOS (*it)) 6921 while (it->bidi_it.charpos < IT_CHARPOS (*it))
@@ -7407,7 +7412,7 @@ move_it_in_display_line (struct it *it,
7407 TO_CHARPOS. */ 7412 TO_CHARPOS. */
7408 7413
7409void 7414void
7410move_it_to (struct it *it, int to_charpos, int to_x, int to_y, int to_vpos, int op) 7415move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos, int op)
7411{ 7416{
7412 enum move_it_result skip, skip2 = MOVE_X_REACHED; 7417 enum move_it_result skip, skip2 = MOVE_X_REACHED;
7413 int line_height, line_start_x = 0, reached = 0; 7418 int line_height, line_start_x = 0, reached = 0;
@@ -7662,7 +7667,7 @@ move_it_vertically_backward (struct it *it, int dy)
7662{ 7667{
7663 int nlines, h; 7668 int nlines, h;
7664 struct it it2, it3; 7669 struct it it2, it3;
7665 int start_pos; 7670 EMACS_INT start_pos;
7666 7671
7667 move_further_back: 7672 move_further_back:
7668 xassert (dy >= 0); 7673 xassert (dy >= 0);
@@ -7823,12 +7828,12 @@ move_it_past_eol (struct it *it)
7823void 7828void
7824move_it_by_lines (struct it *it, int dvpos, int need_y_p) 7829move_it_by_lines (struct it *it, int dvpos, int need_y_p)
7825{ 7830{
7826 struct position pos;
7827 7831
7828 /* The commented-out optimization uses vmotion on terminals. This 7832 /* The commented-out optimization uses vmotion on terminals. This
7829 gives bad results, because elements like it->what, on which 7833 gives bad results, because elements like it->what, on which
7830 callers such as pos_visible_p rely, aren't updated. */ 7834 callers such as pos_visible_p rely, aren't updated. */
7831 /* if (!FRAME_WINDOW_P (it->f)) 7835 /* struct position pos;
7836 if (!FRAME_WINDOW_P (it->f))
7832 { 7837 {
7833 struct text_pos textpos; 7838 struct text_pos textpos;
7834 7839
@@ -7857,7 +7862,7 @@ move_it_by_lines (struct it *it, int dvpos, int need_y_p)
7857 else 7862 else
7858 { 7863 {
7859 struct it it2; 7864 struct it it2;
7860 int start_charpos, i; 7865 EMACS_INT start_charpos, i;
7861 7866
7862 /* Start at the beginning of the screen line containing IT's 7867 /* Start at the beginning of the screen line containing IT's
7863 position. This may actually move vertically backwards, 7868 position. This may actually move vertically backwards,
@@ -7937,7 +7942,7 @@ add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2)
7937 Lisp_Object args[3]; 7942 Lisp_Object args[3];
7938 Lisp_Object msg, fmt; 7943 Lisp_Object msg, fmt;
7939 char *buffer; 7944 char *buffer;
7940 int len; 7945 EMACS_INT len;
7941 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 7946 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
7942 USE_SAFE_ALLOCA; 7947 USE_SAFE_ALLOCA;
7943 7948
@@ -7986,7 +7991,7 @@ message_log_maybe_newline (void)
7986 so the buffer M must NOT point to a Lisp string. */ 7991 so the buffer M must NOT point to a Lisp string. */
7987 7992
7988void 7993void
7989message_dolog (const char *m, int nbytes, int nlflag, int multibyte) 7994message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7990{ 7995{
7991 if (!NILP (Vmemory_full)) 7996 if (!NILP (Vmemory_full))
7992 return; 7997 return;
@@ -7996,8 +8001,8 @@ message_dolog (const char *m, int nbytes, int nlflag, int multibyte)
7996 struct buffer *oldbuf; 8001 struct buffer *oldbuf;
7997 Lisp_Object oldpoint, oldbegv, oldzv; 8002 Lisp_Object oldpoint, oldbegv, oldzv;
7998 int old_windows_or_buffers_changed = windows_or_buffers_changed; 8003 int old_windows_or_buffers_changed = windows_or_buffers_changed;
7999 int point_at_end = 0; 8004 EMACS_INT point_at_end = 0;
8000 int zv_at_end = 0; 8005 EMACS_INT zv_at_end = 0;
8001 Lisp_Object old_deactivate_mark, tem; 8006 Lisp_Object old_deactivate_mark, tem;
8002 struct gcpro gcpro1; 8007 struct gcpro gcpro1;
8003 8008
@@ -8030,7 +8035,8 @@ message_dolog (const char *m, int nbytes, int nlflag, int multibyte)
8030 if (multibyte 8035 if (multibyte
8031 && NILP (current_buffer->enable_multibyte_characters)) 8036 && NILP (current_buffer->enable_multibyte_characters))
8032 { 8037 {
8033 int i, c, char_bytes; 8038 EMACS_INT i;
8039 int c, char_bytes;
8034 unsigned char work[1]; 8040 unsigned char work[1];
8035 8041
8036 /* Convert a multibyte string to single-byte 8042 /* Convert a multibyte string to single-byte
@@ -8047,7 +8053,8 @@ message_dolog (const char *m, int nbytes, int nlflag, int multibyte)
8047 else if (! multibyte 8053 else if (! multibyte
8048 && ! NILP (current_buffer->enable_multibyte_characters)) 8054 && ! NILP (current_buffer->enable_multibyte_characters))
8049 { 8055 {
8050 int i, c, char_bytes; 8056 EMACS_INT i;
8057 int c, char_bytes;
8051 unsigned char *msg = (unsigned char *) m; 8058 unsigned char *msg = (unsigned char *) m;
8052 unsigned char str[MAX_MULTIBYTE_LENGTH]; 8059 unsigned char str[MAX_MULTIBYTE_LENGTH];
8053 /* Convert a single-byte string to multibyte 8060 /* Convert a single-byte string to multibyte
@@ -8065,7 +8072,8 @@ message_dolog (const char *m, int nbytes, int nlflag, int multibyte)
8065 8072
8066 if (nlflag) 8073 if (nlflag)
8067 { 8074 {
8068 int this_bol, this_bol_byte, prev_bol, prev_bol_byte, dup; 8075 EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte;
8076 int dup;
8069 insert_1 ("\n", 1, 1, 0, 0); 8077 insert_1 ("\n", 1, 1, 0, 0);
8070 8078
8071 scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0); 8079 scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0);
@@ -8156,11 +8164,11 @@ message_dolog (const char *m, int nbytes, int nlflag, int multibyte)
8156 value N > 1 if we should also append " [N times]". */ 8164 value N > 1 if we should also append " [N times]". */
8157 8165
8158static int 8166static int
8159message_log_check_duplicate (int prev_bol, int prev_bol_byte, 8167message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte,
8160 int this_bol, int this_bol_byte) 8168 EMACS_INT this_bol, EMACS_INT this_bol_byte)
8161{ 8169{
8162 int i; 8170 EMACS_INT i;
8163 int len = Z_BYTE - 1 - this_bol_byte; 8171 EMACS_INT len = Z_BYTE - 1 - this_bol_byte;
8164 int seen_dots = 0; 8172 int seen_dots = 0;
8165 unsigned char *p1 = BUF_BYTE_ADDRESS (current_buffer, prev_bol_byte); 8173 unsigned char *p1 = BUF_BYTE_ADDRESS (current_buffer, prev_bol_byte);
8166 unsigned char *p2 = BUF_BYTE_ADDRESS (current_buffer, this_bol_byte); 8174 unsigned char *p2 = BUF_BYTE_ADDRESS (current_buffer, this_bol_byte);
@@ -8195,7 +8203,7 @@ message_log_check_duplicate (int prev_bol, int prev_bol_byte,
8195 This may GC, so the buffer M must NOT point to a Lisp string. */ 8203 This may GC, so the buffer M must NOT point to a Lisp string. */
8196 8204
8197void 8205void
8198message2 (const char *m, int nbytes, int multibyte) 8206message2 (const char *m, EMACS_INT nbytes, int multibyte)
8199{ 8207{
8200 /* First flush out any partial line written with print. */ 8208 /* First flush out any partial line written with print. */
8201 message_log_maybe_newline (); 8209 message_log_maybe_newline ();
@@ -8208,7 +8216,7 @@ message2 (const char *m, int nbytes, int multibyte)
8208/* The non-logging counterpart of message2. */ 8216/* The non-logging counterpart of message2. */
8209 8217
8210void 8218void
8211message2_nolog (const char *m, int nbytes, int multibyte) 8219message2_nolog (const char *m, EMACS_INT nbytes, int multibyte)
8212{ 8220{
8213 struct frame *sf = SELECTED_FRAME (); 8221 struct frame *sf = SELECTED_FRAME ();
8214 message_enable_multibyte = multibyte; 8222 message_enable_multibyte = multibyte;
@@ -8270,7 +8278,7 @@ message2_nolog (const char *m, int nbytes, int multibyte)
8270 This function cancels echoing. */ 8278 This function cancels echoing. */
8271 8279
8272void 8280void
8273message3 (Lisp_Object m, int nbytes, int multibyte) 8281message3 (Lisp_Object m, EMACS_INT nbytes, int multibyte)
8274{ 8282{
8275 struct gcpro gcpro1; 8283 struct gcpro gcpro1;
8276 8284
@@ -8302,7 +8310,7 @@ message3 (Lisp_Object m, int nbytes, int multibyte)
8302 and make this cancel echoing. */ 8310 and make this cancel echoing. */
8303 8311
8304void 8312void
8305message3_nolog (Lisp_Object m, int nbytes, int multibyte) 8313message3_nolog (Lisp_Object m, EMACS_INT nbytes, int multibyte)
8306{ 8314{
8307 struct frame *sf = SELECTED_FRAME (); 8315 struct frame *sf = SELECTED_FRAME ();
8308 message_enable_multibyte = multibyte; 8316 message_enable_multibyte = multibyte;
@@ -8488,7 +8496,7 @@ vmessage (const char *m, va_list ap)
8488 { 8496 {
8489 if (m) 8497 if (m)
8490 { 8498 {
8491 int len; 8499 EMACS_INT len;
8492 8500
8493 len = doprnt (FRAME_MESSAGE_BUF (f), 8501 len = doprnt (FRAME_MESSAGE_BUF (f),
8494 FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap); 8502 FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap);
@@ -9185,7 +9193,7 @@ check_message_stack (void)
9185 time we display it---but don't redisplay it now. */ 9193 time we display it---but don't redisplay it now. */
9186 9194
9187void 9195void
9188truncate_echo_area (int nchars) 9196truncate_echo_area (EMACS_INT nchars)
9189{ 9197{
9190 if (nchars == 0) 9198 if (nchars == 0)
9191 echo_area_buffer[0] = Qnil; 9199 echo_area_buffer[0] = Qnil;
@@ -9232,7 +9240,8 @@ truncate_message_1 (EMACS_INT nchars, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4
9232 */ 9240 */
9233 9241
9234void 9242void
9235set_message (const char *s, Lisp_Object string, int nbytes, int multibyte_p) 9243set_message (const char *s, Lisp_Object string,
9244 EMACS_INT nbytes, int multibyte_p)
9236{ 9245{
9237 message_enable_multibyte 9246 message_enable_multibyte
9238 = ((s && multibyte_p) 9247 = ((s && multibyte_p)
@@ -9268,7 +9277,7 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby
9268 9277
9269 if (STRINGP (string)) 9278 if (STRINGP (string))
9270 { 9279 {
9271 int nchars; 9280 EMACS_INT nchars;
9272 9281
9273 if (nbytes == 0) 9282 if (nbytes == 0)
9274 nbytes = SBYTES (string); 9283 nbytes = SBYTES (string);
@@ -9287,7 +9296,8 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby
9287 if (multibyte_p && NILP (current_buffer->enable_multibyte_characters)) 9296 if (multibyte_p && NILP (current_buffer->enable_multibyte_characters))
9288 { 9297 {
9289 /* Convert from multi-byte to single-byte. */ 9298 /* Convert from multi-byte to single-byte. */
9290 int i, c, n; 9299 EMACS_INT i;
9300 int c, n;
9291 unsigned char work[1]; 9301 unsigned char work[1];
9292 9302
9293 /* Convert a multibyte string to single-byte. */ 9303 /* Convert a multibyte string to single-byte. */
@@ -9304,7 +9314,8 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby
9304 && !NILP (current_buffer->enable_multibyte_characters)) 9314 && !NILP (current_buffer->enable_multibyte_characters))
9305 { 9315 {
9306 /* Convert from single-byte to multi-byte. */ 9316 /* Convert from single-byte to multi-byte. */
9307 int i, c, n; 9317 EMACS_INT i;
9318 int c, n;
9308 const unsigned char *msg = (const unsigned char *) s; 9319 const unsigned char *msg = (const unsigned char *) s;
9309 unsigned char str[MAX_MULTIBYTE_LENGTH]; 9320 unsigned char str[MAX_MULTIBYTE_LENGTH];
9310 9321
@@ -9624,7 +9635,7 @@ static int
9624store_mode_line_noprop (const unsigned char *str, int field_width, int precision) 9635store_mode_line_noprop (const unsigned char *str, int field_width, int precision)
9625{ 9636{
9626 int n = 0; 9637 int n = 0;
9627 int dummy, nbytes; 9638 EMACS_INT dummy, nbytes;
9628 9639
9629 /* Copy at most PRECISION chars from STR. */ 9640 /* Copy at most PRECISION chars from STR. */
9630 nbytes = strlen (str); 9641 nbytes = strlen (str);
@@ -10986,7 +10997,7 @@ hscroll_window_tree (Lisp_Object window)
10986 struct it it; 10997 struct it it;
10987 int hscroll; 10998 int hscroll;
10988 struct buffer *saved_current_buffer; 10999 struct buffer *saved_current_buffer;
10989 int pt; 11000 EMACS_INT pt;
10990 int wanted_x; 11001 int wanted_x;
10991 11002
10992 /* Find point in a display of infinite width. */ 11003 /* Find point in a display of infinite width. */
@@ -11099,7 +11110,7 @@ int debug_dvpos, debug_dy;
11099 11110
11100/* Delta in characters and bytes for try_window_id. */ 11111/* Delta in characters and bytes for try_window_id. */
11101 11112
11102int debug_delta, debug_delta_bytes; 11113EMACS_INT debug_delta, debug_delta_bytes;
11103 11114
11104/* Values of window_end_pos and window_end_vpos at the end of 11115/* Values of window_end_pos and window_end_vpos at the end of
11105 try_window_id. */ 11116 try_window_id. */
@@ -11151,7 +11162,8 @@ debug_method_add (w, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
11151 redisplay_internal for display optimization. */ 11162 redisplay_internal for display optimization. */
11152 11163
11153static INLINE int 11164static INLINE int
11154text_outside_line_unchanged_p (struct window *w, int start, int end) 11165text_outside_line_unchanged_p (struct window *w,
11166 EMACS_INT start, EMACS_INT end)
11155{ 11167{
11156 int unchanged_p = 1; 11168 int unchanged_p = 1;
11157 11169
@@ -11374,8 +11386,8 @@ overlay_arrow_at_row (struct it *it, struct glyph_row *row)
11374 position. BUF and PT are the current point buffer and position. */ 11386 position. BUF and PT are the current point buffer and position. */
11375 11387
11376int 11388int
11377check_point_in_composition (struct buffer *prev_buf, int prev_pt, 11389check_point_in_composition (struct buffer *prev_buf, EMACS_INT prev_pt,
11378 struct buffer *buf, int pt) 11390 struct buffer *buf, EMACS_INT pt)
11379{ 11391{
11380 EMACS_INT start, end; 11392 EMACS_INT start, end;
11381 Lisp_Object prop; 11393 Lisp_Object prop;
@@ -11428,7 +11440,7 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
11428 if (!b->clip_changed 11440 if (!b->clip_changed
11429 && BUFFERP (w->buffer) && !NILP (w->window_end_valid)) 11441 && BUFFERP (w->buffer) && !NILP (w->window_end_valid))
11430 { 11442 {
11431 int pt; 11443 EMACS_INT pt;
11432 11444
11433 if (w == XWINDOW (selected_window)) 11445 if (w == XWINDOW (selected_window))
11434 pt = BUF_PT (current_buffer); 11446 pt = BUF_PT (current_buffer);
@@ -11830,7 +11842,7 @@ redisplay_internal (int preserve_echo_area)
11830 { 11842 {
11831 struct glyph_row *row 11843 struct glyph_row *row
11832 = MATRIX_ROW (w->current_matrix, this_line_vpos + 1); 11844 = MATRIX_ROW (w->current_matrix, this_line_vpos + 1);
11833 int delta, delta_bytes; 11845 EMACS_INT delta, delta_bytes;
11834 11846
11835 /* We used to distinguish between two cases here, 11847 /* We used to distinguish between two cases here,
11836 conditioned by Z - CHARPOS (tlendpos) == ZV, for 11848 conditioned by Z - CHARPOS (tlendpos) == ZV, for
@@ -12459,14 +12471,15 @@ redisplay_window_1 (Lisp_Object window)
12459 12471
12460int 12472int
12461set_cursor_from_row (struct window *w, struct glyph_row *row, 12473set_cursor_from_row (struct window *w, struct glyph_row *row,
12462 struct glyph_matrix *matrix, int delta, int delta_bytes, 12474 struct glyph_matrix *matrix,
12475 EMACS_INT delta, EMACS_INT delta_bytes,
12463 int dy, int dvpos) 12476 int dy, int dvpos)
12464{ 12477{
12465 struct glyph *glyph = row->glyphs[TEXT_AREA]; 12478 struct glyph *glyph = row->glyphs[TEXT_AREA];
12466 struct glyph *end = glyph + row->used[TEXT_AREA]; 12479 struct glyph *end = glyph + row->used[TEXT_AREA];
12467 struct glyph *cursor = NULL; 12480 struct glyph *cursor = NULL;
12468 /* The last known character position in row. */ 12481 /* The last known character position in row. */
12469 int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; 12482 EMACS_INT last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
12470 int x = row->x; 12483 int x = row->x;
12471 EMACS_INT pt_old = PT - delta; 12484 EMACS_INT pt_old = PT - delta;
12472 EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta; 12485 EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta;
@@ -12603,7 +12616,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
12603 else if (STRINGP (glyph->object)) 12616 else if (STRINGP (glyph->object))
12604 { 12617 {
12605 Lisp_Object chprop; 12618 Lisp_Object chprop;
12606 int glyph_pos = glyph->charpos; 12619 EMACS_INT glyph_pos = glyph->charpos;
12607 12620
12608 chprop = Fget_char_property (make_number (glyph_pos), Qcursor, 12621 chprop = Fget_char_property (make_number (glyph_pos), Qcursor,
12609 glyph->object); 12622 glyph->object);
@@ -12670,7 +12683,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
12670 else if (STRINGP (glyph->object)) 12683 else if (STRINGP (glyph->object))
12671 { 12684 {
12672 Lisp_Object chprop; 12685 Lisp_Object chprop;
12673 int glyph_pos = glyph->charpos; 12686 EMACS_INT glyph_pos = glyph->charpos;
12674 12687
12675 chprop = Fget_char_property (make_number (glyph_pos), Qcursor, 12688 chprop = Fget_char_property (make_number (glyph_pos), Qcursor,
12676 glyph->object); 12689 glyph->object);
@@ -12788,7 +12801,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
12788 be a character in the string with the 12801 be a character in the string with the
12789 `cursor' property, which means display 12802 `cursor' property, which means display
12790 cursor on that character's glyph. */ 12803 cursor on that character's glyph. */
12791 int strpos = glyph->charpos; 12804 EMACS_INT strpos = glyph->charpos;
12792 12805
12793 cursor = glyph; 12806 cursor = glyph;
12794 for (glyph += incr; 12807 for (glyph += incr;
@@ -12797,7 +12810,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
12797 glyph += incr) 12810 glyph += incr)
12798 { 12811 {
12799 Lisp_Object cprop; 12812 Lisp_Object cprop;
12800 int gpos = glyph->charpos; 12813 EMACS_INT gpos = glyph->charpos;
12801 12814
12802 cprop = Fget_char_property (make_number (gpos), 12815 cprop = Fget_char_property (make_number (gpos),
12803 Qcursor, 12816 Qcursor,
@@ -13687,7 +13700,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
13687void 13700void
13688set_vertical_scroll_bar (struct window *w) 13701set_vertical_scroll_bar (struct window *w)
13689{ 13702{
13690 int start, end, whole; 13703 EMACS_INT start, end, whole;
13691 13704
13692 /* Calculate the start and end positions for the current window. 13705 /* Calculate the start and end positions for the current window.
13693 At some point, it would be nice to choose between scrollbars 13706 At some point, it would be nice to choose between scrollbars
@@ -13751,7 +13764,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
13751 int rc; 13764 int rc;
13752 int centering_position = -1; 13765 int centering_position = -1;
13753 int last_line_misfit = 0; 13766 int last_line_misfit = 0;
13754 int beg_unchanged, end_unchanged; 13767 EMACS_INT beg_unchanged, end_unchanged;
13755 13768
13756 SET_TEXT_POS (lpoint, PT, PT_BYTE); 13769 SET_TEXT_POS (lpoint, PT, PT_BYTE);
13757 opoint = lpoint; 13770 opoint = lpoint;
@@ -13893,8 +13906,8 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
13893 window, set up appropriate value. */ 13906 window, set up appropriate value. */
13894 if (!EQ (window, selected_window)) 13907 if (!EQ (window, selected_window))
13895 { 13908 {
13896 int new_pt = XMARKER (w->pointm)->charpos; 13909 EMACS_INT new_pt = XMARKER (w->pointm)->charpos;
13897 int new_pt_byte = marker_byte_position (w->pointm); 13910 EMACS_INT new_pt_byte = marker_byte_position (w->pointm);
13898 if (new_pt < BEGV) 13911 if (new_pt < BEGV)
13899 { 13912 {
13900 new_pt = BEGV; 13913 new_pt = BEGV;
@@ -15052,7 +15065,7 @@ try_window_reusing_current_matrix (struct window *w)
15052 15065
15053static struct glyph_row *find_last_unchanged_at_beg_row (struct window *); 15066static struct glyph_row *find_last_unchanged_at_beg_row (struct window *);
15054static struct glyph_row *find_first_unchanged_at_end_row (struct window *, 15067static struct glyph_row *find_first_unchanged_at_end_row (struct window *,
15055 int *, int *); 15068 EMACS_INT *, EMACS_INT *);
15056static struct glyph_row * 15069static struct glyph_row *
15057find_last_row_displaying_text (struct glyph_matrix *, struct it *, 15070find_last_row_displaying_text (struct glyph_matrix *, struct it *,
15058 struct glyph_row *); 15071 struct glyph_row *);
@@ -15100,7 +15113,7 @@ find_last_row_displaying_text (struct glyph_matrix *matrix, struct it *it,
15100static struct glyph_row * 15113static struct glyph_row *
15101find_last_unchanged_at_beg_row (struct window *w) 15114find_last_unchanged_at_beg_row (struct window *w)
15102{ 15115{
15103 int first_changed_pos = BEG + BEG_UNCHANGED; 15116 EMACS_INT first_changed_pos = BEG + BEG_UNCHANGED;
15104 struct glyph_row *row; 15117 struct glyph_row *row;
15105 struct glyph_row *row_found = NULL; 15118 struct glyph_row *row_found = NULL;
15106 int yb = window_text_bottom_y (w); 15119 int yb = window_text_bottom_y (w);
@@ -15147,7 +15160,8 @@ find_last_unchanged_at_beg_row (struct window *w)
15147 changes. */ 15160 changes. */
15148 15161
15149static struct glyph_row * 15162static struct glyph_row *
15150find_first_unchanged_at_end_row (struct window *w, int *delta, int *delta_bytes) 15163find_first_unchanged_at_end_row (struct window *w,
15164 EMACS_INT *delta, EMACS_INT *delta_bytes)
15151{ 15165{
15152 struct glyph_row *row; 15166 struct glyph_row *row;
15153 struct glyph_row *row_found = NULL; 15167 struct glyph_row *row_found = NULL;
@@ -15175,9 +15189,11 @@ find_first_unchanged_at_end_row (struct window *w, int *delta, int *delta_bytes)
15175 corresponds to window_end_pos. This allows us to translate 15189 corresponds to window_end_pos. This allows us to translate
15176 buffer positions in the current matrix to current buffer 15190 buffer positions in the current matrix to current buffer
15177 positions for characters not in changed text. */ 15191 positions for characters not in changed text. */
15178 int Z_old = MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); 15192 EMACS_INT Z_old =
15179 int Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; 15193 MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos);
15180 int last_unchanged_pos, last_unchanged_pos_old; 15194 EMACS_INT Z_BYTE_old =
15195 MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
15196 EMACS_INT last_unchanged_pos, last_unchanged_pos_old;
15181 struct glyph_row *first_text_row 15197 struct glyph_row *first_text_row
15182 = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 15198 = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
15183 15199
@@ -15264,8 +15280,8 @@ sync_frame_with_window_matrix_rows (struct window *w)
15264 containing CHARPOS or null. */ 15280 containing CHARPOS or null. */
15265 15281
15266struct glyph_row * 15282struct glyph_row *
15267row_containing_pos (struct window *w, int charpos, struct glyph_row *start, 15283row_containing_pos (struct window *w, EMACS_INT charpos,
15268 struct glyph_row *end, int dy) 15284 struct glyph_row *start, struct glyph_row *end, int dy)
15269{ 15285{
15270 struct glyph_row *row = start; 15286 struct glyph_row *row = start;
15271 struct glyph_row *best_row = NULL; 15287 struct glyph_row *best_row = NULL;
@@ -15378,13 +15394,14 @@ try_window_id (struct window *w)
15378 struct glyph_row *bottom_row; 15394 struct glyph_row *bottom_row;
15379 int bottom_vpos; 15395 int bottom_vpos;
15380 struct it it; 15396 struct it it;
15381 int delta = 0, delta_bytes = 0, stop_pos, dvpos, dy; 15397 EMACS_INT delta = 0, delta_bytes = 0, stop_pos;
15398 int dvpos, dy;
15382 struct text_pos start_pos; 15399 struct text_pos start_pos;
15383 struct run run; 15400 struct run run;
15384 int first_unchanged_at_end_vpos = 0; 15401 int first_unchanged_at_end_vpos = 0;
15385 struct glyph_row *last_text_row, *last_text_row_at_end; 15402 struct glyph_row *last_text_row, *last_text_row_at_end;
15386 struct text_pos start; 15403 struct text_pos start;
15387 int first_changed_charpos, last_changed_charpos; 15404 EMACS_INT first_changed_charpos, last_changed_charpos;
15388 15405
15389#if GLYPH_DEBUG 15406#if GLYPH_DEBUG
15390 if (inhibit_try_window_id) 15407 if (inhibit_try_window_id)
@@ -15511,7 +15528,7 @@ try_window_id (struct window *w)
15511 || (last_changed_charpos < CHARPOS (start) - 1 15528 || (last_changed_charpos < CHARPOS (start) - 1
15512 && FETCH_BYTE (BYTEPOS (start) - 1) == '\n'))) 15529 && FETCH_BYTE (BYTEPOS (start) - 1) == '\n')))
15513 { 15530 {
15514 int Z_old, delta, Z_BYTE_old, delta_bytes; 15531 EMACS_INT Z_old, delta, Z_BYTE_old, delta_bytes;
15515 struct glyph_row *r0; 15532 struct glyph_row *r0;
15516 15533
15517 /* Compute how many chars/bytes have been added to or removed 15534 /* Compute how many chars/bytes have been added to or removed
@@ -16210,7 +16227,7 @@ dump_glyph (row, glyph, area)
16210 if (glyph->u.cmp.automatic) 16227 if (glyph->u.cmp.automatic)
16211 fprintf (stderr, 16228 fprintf (stderr,
16212 "[%d-%d]", 16229 "[%d-%d]",
16213 glyph->u.cmp.from, glyph->u.cmp.to); 16230 glyph->slice.cmp.from, glyph->slice.cmp.to);
16214 fprintf (stderr, " . %4d %1.1d%1.1d\n", 16231 fprintf (stderr, " . %4d %1.1d%1.1d\n",
16215 glyph->face_id, 16232 glyph->face_id,
16216 glyph->left_box_line_p, 16233 glyph->left_box_line_p,
@@ -16895,9 +16912,9 @@ extend_face_to_end_of_line (struct it *it)
16895 trailing whitespace. */ 16912 trailing whitespace. */
16896 16913
16897static int 16914static int
16898trailing_whitespace_p (int charpos) 16915trailing_whitespace_p (EMACS_INT charpos)
16899{ 16916{
16900 int bytepos = CHAR_TO_BYTE (charpos); 16917 EMACS_INT bytepos = CHAR_TO_BYTE (charpos);
16901 int c = 0; 16918 int c = 0;
16902 16919
16903 while (bytepos < ZV_BYTE 16920 while (bytepos < ZV_BYTE
@@ -17992,8 +18009,9 @@ See also `bidi-paragraph-direction'. */)
17992 itb.bytepos = bytepos; 18009 itb.bytepos = bytepos;
17993 itb.first_elt = 1; 18010 itb.first_elt = 1;
17994 itb.separator_limit = -1; 18011 itb.separator_limit = -1;
18012 itb.paragraph_dir = NEUTRAL_DIR;
17995 18013
17996 bidi_paragraph_init (NEUTRAL_DIR, &itb); 18014 bidi_paragraph_init (NEUTRAL_DIR, &itb, 1);
17997 if (buf != current_buffer) 18015 if (buf != current_buffer)
17998 set_buffer_temp (old); 18016 set_buffer_temp (old);
17999 switch (itb.paragraph_dir) 18017 switch (itb.paragraph_dir)
@@ -18372,7 +18390,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18372 { 18390 {
18373 /* A string: output it and check for %-constructs within it. */ 18391 /* A string: output it and check for %-constructs within it. */
18374 unsigned char c; 18392 unsigned char c;
18375 int offset = 0; 18393 EMACS_INT offset = 0;
18376 18394
18377 if (SCHARS (elt) > 0 18395 if (SCHARS (elt) > 0
18378 && (!NILP (props) || risky)) 18396 && (!NILP (props) || risky))
@@ -18469,7 +18487,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18469 && (mode_line_target != MODE_LINE_DISPLAY 18487 && (mode_line_target != MODE_LINE_DISPLAY
18470 || it->current_x < it->last_visible_x)) 18488 || it->current_x < it->last_visible_x))
18471 { 18489 {
18472 int last_offset = offset; 18490 EMACS_INT last_offset = offset;
18473 18491
18474 /* Advance to end of string or next format specifier. */ 18492 /* Advance to end of string or next format specifier. */
18475 while ((c = SREF (elt, offset++)) != '\0' && c != '%') 18493 while ((c = SREF (elt, offset++)) != '\0' && c != '%')
@@ -18477,7 +18495,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18477 18495
18478 if (offset - 1 != last_offset) 18496 if (offset - 1 != last_offset)
18479 { 18497 {
18480 int nchars, nbytes; 18498 EMACS_INT nchars, nbytes;
18481 18499
18482 /* Output to end of string or up to '%'. Field width 18500 /* Output to end of string or up to '%'. Field width
18483 is length of string. Don't output more than 18501 is length of string. Don't output more than
@@ -18496,11 +18514,11 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18496 break; 18514 break;
18497 case MODE_LINE_STRING: 18515 case MODE_LINE_STRING:
18498 { 18516 {
18499 int bytepos = last_offset; 18517 EMACS_INT bytepos = last_offset;
18500 int charpos = string_byte_to_char (elt, bytepos); 18518 EMACS_INT charpos = string_byte_to_char (elt, bytepos);
18501 int endpos = (precision <= 0 18519 EMACS_INT endpos = (precision <= 0
18502 ? string_byte_to_char (elt, offset) 18520 ? string_byte_to_char (elt, offset)
18503 : charpos + nchars); 18521 : charpos + nchars);
18504 18522
18505 n += store_mode_line_string (NULL, 18523 n += store_mode_line_string (NULL,
18506 Fsubstring (elt, make_number (charpos), 18524 Fsubstring (elt, make_number (charpos),
@@ -18510,8 +18528,8 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18510 break; 18528 break;
18511 case MODE_LINE_DISPLAY: 18529 case MODE_LINE_DISPLAY:
18512 { 18530 {
18513 int bytepos = last_offset; 18531 EMACS_INT bytepos = last_offset;
18514 int charpos = string_byte_to_char (elt, bytepos); 18532 EMACS_INT charpos = string_byte_to_char (elt, bytepos);
18515 18533
18516 if (precision <= 0) 18534 if (precision <= 0)
18517 nchars = string_byte_to_char (elt, offset) - charpos; 18535 nchars = string_byte_to_char (elt, offset) - charpos;
@@ -18524,7 +18542,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18524 } 18542 }
18525 else /* c == '%' */ 18543 else /* c == '%' */
18526 { 18544 {
18527 int percent_position = offset; 18545 EMACS_INT percent_position = offset;
18528 18546
18529 /* Get the specified minimum width. Zero means 18547 /* Get the specified minimum width. Zero means
18530 don't pad. */ 18548 don't pad. */
@@ -18546,7 +18564,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18546 else if (c != 0) 18564 else if (c != 0)
18547 { 18565 {
18548 int multibyte; 18566 int multibyte;
18549 int bytepos, charpos; 18567 EMACS_INT bytepos, charpos;
18550 const unsigned char *spec; 18568 const unsigned char *spec;
18551 Lisp_Object string; 18569 Lisp_Object string;
18552 18570
@@ -18820,7 +18838,7 @@ static int
18820store_mode_line_string (const char *string, Lisp_Object lisp_string, int copy_string, 18838store_mode_line_string (const char *string, Lisp_Object lisp_string, int copy_string,
18821 int field_width, int precision, Lisp_Object props) 18839 int field_width, int precision, Lisp_Object props)
18822{ 18840{
18823 int len; 18841 EMACS_INT len;
18824 int n = 0; 18842 int n = 0;
18825 18843
18826 if (string != NULL) 18844 if (string != NULL)
@@ -19365,22 +19383,23 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19365 19383
19366 case 'i': 19384 case 'i':
19367 { 19385 {
19368 int size = ZV - BEGV; 19386 EMACS_INT size = ZV - BEGV;
19369 pint2str (decode_mode_spec_buf, field_width, size); 19387 pint2str (decode_mode_spec_buf, field_width, size);
19370 return decode_mode_spec_buf; 19388 return decode_mode_spec_buf;
19371 } 19389 }
19372 19390
19373 case 'I': 19391 case 'I':
19374 { 19392 {
19375 int size = ZV - BEGV; 19393 EMACS_INT size = ZV - BEGV;
19376 pint2hrstr (decode_mode_spec_buf, field_width, size); 19394 pint2hrstr (decode_mode_spec_buf, field_width, size);
19377 return decode_mode_spec_buf; 19395 return decode_mode_spec_buf;
19378 } 19396 }
19379 19397
19380 case 'l': 19398 case 'l':
19381 { 19399 {
19382 int startpos, startpos_byte, line, linepos, linepos_byte; 19400 EMACS_INT startpos, startpos_byte, line, linepos, linepos_byte;
19383 int topline, nlines, junk, height; 19401 int topline, nlines, height;
19402 EMACS_INT junk;
19384 19403
19385 /* %c and %l are ignored in `frame-title-format'. */ 19404 /* %c and %l are ignored in `frame-title-format'. */
19386 if (mode_line_target == MODE_LINE_TITLE) 19405 if (mode_line_target == MODE_LINE_TITLE)
@@ -19441,9 +19460,9 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19441 else if (nlines < height + 25 || nlines > height * 3 + 50 19460 else if (nlines < height + 25 || nlines > height * 3 + 50
19442 || linepos == BUF_BEGV (b)) 19461 || linepos == BUF_BEGV (b))
19443 { 19462 {
19444 int limit = BUF_BEGV (b); 19463 EMACS_INT limit = BUF_BEGV (b);
19445 int limit_byte = BUF_BEGV_BYTE (b); 19464 EMACS_INT limit_byte = BUF_BEGV_BYTE (b);
19446 int position; 19465 EMACS_INT position;
19447 int distance = (height * 2 + 30) * line_number_display_limit_width; 19466 int distance = (height * 2 + 30) * line_number_display_limit_width;
19448 19467
19449 if (startpos - distance > limit) 19468 if (startpos - distance > limit)
@@ -19505,8 +19524,8 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19505 19524
19506 case 'p': 19525 case 'p':
19507 { 19526 {
19508 int pos = marker_position (w->start); 19527 EMACS_INT pos = marker_position (w->start);
19509 int total = BUF_ZV (b) - BUF_BEGV (b); 19528 EMACS_INT total = BUF_ZV (b) - BUF_BEGV (b);
19510 19529
19511 if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b)) 19530 if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b))
19512 { 19531 {
@@ -19528,7 +19547,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19528 so get us a 2-digit number that is close. */ 19547 so get us a 2-digit number that is close. */
19529 if (total == 100) 19548 if (total == 100)
19530 total = 99; 19549 total = 99;
19531 sprintf (decode_mode_spec_buf, "%2d%%", total); 19550 sprintf (decode_mode_spec_buf, "%2ld%%", (long)total);
19532 return decode_mode_spec_buf; 19551 return decode_mode_spec_buf;
19533 } 19552 }
19534 } 19553 }
@@ -19536,9 +19555,9 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19536 /* Display percentage of size above the bottom of the screen. */ 19555 /* Display percentage of size above the bottom of the screen. */
19537 case 'P': 19556 case 'P':
19538 { 19557 {
19539 int toppos = marker_position (w->start); 19558 EMACS_INT toppos = marker_position (w->start);
19540 int botpos = BUF_Z (b) - XFASTINT (w->window_end_pos); 19559 EMACS_INT botpos = BUF_Z (b) - XFASTINT (w->window_end_pos);
19541 int total = BUF_ZV (b) - BUF_BEGV (b); 19560 EMACS_INT total = BUF_ZV (b) - BUF_BEGV (b);
19542 19561
19543 if (botpos >= BUF_ZV (b)) 19562 if (botpos >= BUF_ZV (b))
19544 { 19563 {
@@ -19559,9 +19578,9 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19559 if (total == 100) 19578 if (total == 100)
19560 total = 99; 19579 total = 99;
19561 if (toppos <= BUF_BEGV (b)) 19580 if (toppos <= BUF_BEGV (b))
19562 sprintf (decode_mode_spec_buf, "Top%2d%%", total); 19581 sprintf (decode_mode_spec_buf, "Top%2ld%%", (long)total);
19563 else 19582 else
19564 sprintf (decode_mode_spec_buf, "%2d%%", total); 19583 sprintf (decode_mode_spec_buf, "%2ld%%", (long)total);
19565 return decode_mode_spec_buf; 19584 return decode_mode_spec_buf;
19566 } 19585 }
19567 } 19586 }
@@ -19652,8 +19671,9 @@ decode_mode_spec (struct window *w, register int c, int field_width,
19652 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */ 19671 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
19653 19672
19654static int 19673static int
19655display_count_lines (int start, int start_byte, int limit_byte, int count, 19674display_count_lines (EMACS_INT start, EMACS_INT start_byte,
19656 int *byte_pos_ptr) 19675 EMACS_INT limit_byte, int count,
19676 EMACS_INT *byte_pos_ptr)
19657{ 19677{
19658 register unsigned char *cursor; 19678 register unsigned char *cursor;
19659 unsigned char *base; 19679 unsigned char *base;
@@ -20595,8 +20615,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
20595 glyph = s->row->glyphs[s->area] + start; 20615 glyph = s->row->glyphs[s->area] + start;
20596 last = s->row->glyphs[s->area] + end; 20616 last = s->row->glyphs[s->area] + end;
20597 s->cmp_id = glyph->u.cmp.id; 20617 s->cmp_id = glyph->u.cmp.id;
20598 s->cmp_from = glyph->u.cmp.from; 20618 s->cmp_from = glyph->slice.cmp.from;
20599 s->cmp_to = glyph->u.cmp.to + 1; 20619 s->cmp_to = glyph->slice.cmp.to + 1;
20600 s->face = FACE_FROM_ID (s->f, face_id); 20620 s->face = FACE_FROM_ID (s->f, face_id);
20601 lgstring = composition_gstring_from_id (s->cmp_id); 20621 lgstring = composition_gstring_from_id (s->cmp_id);
20602 s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring)); 20622 s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring));
@@ -20604,8 +20624,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
20604 while (glyph < last 20624 while (glyph < last
20605 && glyph->u.cmp.automatic 20625 && glyph->u.cmp.automatic
20606 && glyph->u.cmp.id == s->cmp_id 20626 && glyph->u.cmp.id == s->cmp_id
20607 && s->cmp_to == glyph->u.cmp.from) 20627 && s->cmp_to == glyph->slice.cmp.from)
20608 s->cmp_to = (glyph++)->u.cmp.to + 1; 20628 s->cmp_to = (glyph++)->slice.cmp.to + 1;
20609 20629
20610 for (i = s->cmp_from; i < s->cmp_to; i++) 20630 for (i = s->cmp_from; i < s->cmp_to; i++)
20611 { 20631 {
@@ -20695,7 +20715,7 @@ fill_image_glyph_string (struct glyph_string *s)
20695 xassert (s->first_glyph->type == IMAGE_GLYPH); 20715 xassert (s->first_glyph->type == IMAGE_GLYPH);
20696 s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id); 20716 s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id);
20697 xassert (s->img); 20717 xassert (s->img);
20698 s->slice = s->first_glyph->slice; 20718 s->slice = s->first_glyph->slice.img;
20699 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 20719 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
20700 s->font = s->face->font; 20720 s->font = s->face->font;
20701 s->width = s->first_glyph->pixel_width; 20721 s->width = s->first_glyph->pixel_width;
@@ -20801,8 +20821,8 @@ x_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *rig
20801 Lisp_Object gstring = composition_gstring_from_id (glyph->u.cmp.id); 20821 Lisp_Object gstring = composition_gstring_from_id (glyph->u.cmp.id);
20802 struct font_metrics metrics; 20822 struct font_metrics metrics;
20803 20823
20804 composition_gstring_width (gstring, glyph->u.cmp.from, 20824 composition_gstring_width (gstring, glyph->slice.cmp.from,
20805 glyph->u.cmp.to + 1, &metrics); 20825 glyph->slice.cmp.to + 1, &metrics);
20806 if (metrics.rbearing > metrics.width) 20826 if (metrics.rbearing > metrics.width)
20807 *right = metrics.rbearing - metrics.width; 20827 *right = metrics.rbearing - metrics.width;
20808 if (metrics.lbearing < 0) 20828 if (metrics.lbearing < 0)
@@ -21507,7 +21527,7 @@ append_glyph (struct it *it)
21507 glyph->glyph_not_available_p = it->glyph_not_available_p; 21527 glyph->glyph_not_available_p = it->glyph_not_available_p;
21508 glyph->face_id = it->face_id; 21528 glyph->face_id = it->face_id;
21509 glyph->u.ch = it->char_to_display; 21529 glyph->u.ch = it->char_to_display;
21510 glyph->slice = null_glyph_slice; 21530 glyph->slice.img = null_glyph_slice;
21511 glyph->font_type = FONT_TYPE_UNKNOWN; 21531 glyph->font_type = FONT_TYPE_UNKNOWN;
21512 if (it->bidi_p) 21532 if (it->bidi_p)
21513 { 21533 {
@@ -21564,13 +21584,14 @@ append_composite_glyph (struct it *it)
21564 { 21584 {
21565 glyph->u.cmp.automatic = 0; 21585 glyph->u.cmp.automatic = 0;
21566 glyph->u.cmp.id = it->cmp_it.id; 21586 glyph->u.cmp.id = it->cmp_it.id;
21587 glyph->slice.cmp.from = glyph->slice.cmp.to = 0;
21567 } 21588 }
21568 else 21589 else
21569 { 21590 {
21570 glyph->u.cmp.automatic = 1; 21591 glyph->u.cmp.automatic = 1;
21571 glyph->u.cmp.id = it->cmp_it.id; 21592 glyph->u.cmp.id = it->cmp_it.id;
21572 glyph->u.cmp.from = it->cmp_it.from; 21593 glyph->slice.cmp.from = it->cmp_it.from;
21573 glyph->u.cmp.to = it->cmp_it.to - 1; 21594 glyph->slice.cmp.to = it->cmp_it.to - 1;
21574 } 21595 }
21575 glyph->avoid_cursor_p = it->avoid_cursor_p; 21596 glyph->avoid_cursor_p = it->avoid_cursor_p;
21576 glyph->multibyte_p = it->multibyte_p; 21597 glyph->multibyte_p = it->multibyte_p;
@@ -21581,7 +21602,6 @@ append_composite_glyph (struct it *it)
21581 glyph->padding_p = 0; 21602 glyph->padding_p = 0;
21582 glyph->glyph_not_available_p = 0; 21603 glyph->glyph_not_available_p = 0;
21583 glyph->face_id = it->face_id; 21604 glyph->face_id = it->face_id;
21584 glyph->slice = null_glyph_slice;
21585 glyph->font_type = FONT_TYPE_UNKNOWN; 21605 glyph->font_type = FONT_TYPE_UNKNOWN;
21586 if (it->bidi_p) 21606 if (it->bidi_p)
21587 { 21607 {
@@ -21760,7 +21780,7 @@ produce_image_glyph (struct it *it)
21760 glyph->glyph_not_available_p = 0; 21780 glyph->glyph_not_available_p = 0;
21761 glyph->face_id = it->face_id; 21781 glyph->face_id = it->face_id;
21762 glyph->u.img_id = img->id; 21782 glyph->u.img_id = img->id;
21763 glyph->slice = slice; 21783 glyph->slice.img = slice;
21764 glyph->font_type = FONT_TYPE_UNKNOWN; 21784 glyph->font_type = FONT_TYPE_UNKNOWN;
21765 if (it->bidi_p) 21785 if (it->bidi_p)
21766 { 21786 {
@@ -21821,7 +21841,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object,
21821 glyph->face_id = it->face_id; 21841 glyph->face_id = it->face_id;
21822 glyph->u.stretch.ascent = ascent; 21842 glyph->u.stretch.ascent = ascent;
21823 glyph->u.stretch.height = height; 21843 glyph->u.stretch.height = height;
21824 glyph->slice = null_glyph_slice; 21844 glyph->slice.img = null_glyph_slice;
21825 glyph->font_type = FONT_TYPE_UNKNOWN; 21845 glyph->font_type = FONT_TYPE_UNKNOWN;
21826 if (it->bidi_p) 21846 if (it->bidi_p)
21827 { 21847 {
@@ -21910,11 +21930,7 @@ produce_stretch_glyph (struct it *it)
21910 21930
21911 it2 = *it; 21931 it2 = *it;
21912 if (it->multibyte_p) 21932 if (it->multibyte_p)
21913 { 21933 it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len);
21914 int maxlen = ((IT_BYTEPOS (*it) >= GPT ? ZV : GPT)
21915 - IT_BYTEPOS (*it));
21916 it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len);
21917 }
21918 else 21934 else
21919 { 21935 {
21920 it2.c = it2.char_to_display = *p, it2.len = 1; 21936 it2.c = it2.char_to_display = *p, it2.len = 1;
@@ -22400,7 +22416,7 @@ x_produce_glyphs (struct it *it)
22400 XChar2b char2b; 22416 XChar2b char2b;
22401 struct font_metrics *pcm; 22417 struct font_metrics *pcm;
22402 int font_not_found_p; 22418 int font_not_found_p;
22403 int pos; 22419 EMACS_INT pos;
22404 22420
22405 for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--) 22421 for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--)
22406 if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t') 22422 if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t')
@@ -24162,7 +24178,8 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
24162 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 24178 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
24163 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 24179 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
24164 Lisp_Object pointer = Qnil; 24180 Lisp_Object pointer = Qnil;
24165 int charpos, dx, dy, width, height; 24181 int dx, dy, width, height;
24182 EMACS_INT charpos;
24166 Lisp_Object string, object = Qnil; 24183 Lisp_Object string, object = Qnil;
24167 Lisp_Object pos, help; 24184 Lisp_Object pos, help;
24168 24185
@@ -24493,7 +24510,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
24493 Lisp_Object *overlay_vec = NULL; 24510 Lisp_Object *overlay_vec = NULL;
24494 int noverlays; 24511 int noverlays;
24495 struct buffer *obuf; 24512 struct buffer *obuf;
24496 int obegv, ozv, same_region; 24513 EMACS_INT obegv, ozv;
24514 int same_region;
24497 24515
24498 /* Find the glyph under X/Y. */ 24516 /* Find the glyph under X/Y. */
24499 glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area); 24517 glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area);
@@ -24508,8 +24526,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
24508 if ((image_map = Fplist_get (XCDR (img->spec), QCmap), 24526 if ((image_map = Fplist_get (XCDR (img->spec), QCmap),
24509 !NILP (image_map)) 24527 !NILP (image_map))
24510 && (hotspot = find_hot_spot (image_map, 24528 && (hotspot = find_hot_spot (image_map,
24511 glyph->slice.x + dx, 24529 glyph->slice.img.x + dx,
24512 glyph->slice.y + dy), 24530 glyph->slice.img.y + dy),
24513 CONSP (hotspot)) 24531 CONSP (hotspot))
24514 && (hotspot = XCDR (hotspot), CONSP (hotspot))) 24532 && (hotspot = XCDR (hotspot), CONSP (hotspot)))
24515 { 24533 {
@@ -24679,7 +24697,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
24679 /* If we are on a display string with no mouse-face, 24697 /* If we are on a display string with no mouse-face,
24680 check if the text under it has one. */ 24698 check if the text under it has one. */
24681 struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); 24699 struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
24682 int start = MATRIX_ROW_START_CHARPOS (r); 24700 EMACS_INT start = MATRIX_ROW_START_CHARPOS (r);
24683 pos = string_buffer_position (w, object, start); 24701 pos = string_buffer_position (w, object, start);
24684 if (pos > 0) 24702 if (pos > 0)
24685 { 24703 {
@@ -24758,7 +24776,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
24758 else 24776 else
24759 { 24777 {
24760 Lisp_Object object = glyph->object; 24778 Lisp_Object object = glyph->object;
24761 int charpos = glyph->charpos; 24779 EMACS_INT charpos = glyph->charpos;
24762 24780
24763 /* Try text properties. */ 24781 /* Try text properties. */
24764 if (STRINGP (object) 24782 if (STRINGP (object)
@@ -24773,7 +24791,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
24773 see if the buffer text ``under'' it does. */ 24791 see if the buffer text ``under'' it does. */
24774 struct glyph_row *r 24792 struct glyph_row *r
24775 = MATRIX_ROW (w->current_matrix, vpos); 24793 = MATRIX_ROW (w->current_matrix, vpos);
24776 int start = MATRIX_ROW_START_CHARPOS (r); 24794 EMACS_INT start = MATRIX_ROW_START_CHARPOS (r);
24777 EMACS_INT pos = string_buffer_position (w, object, start); 24795 EMACS_INT pos = string_buffer_position (w, object, start);
24778 if (pos > 0) 24796 if (pos > 0)
24779 { 24797 {
@@ -24813,7 +24831,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
24813 if (NILP (pointer)) 24831 if (NILP (pointer))
24814 { 24832 {
24815 Lisp_Object object = glyph->object; 24833 Lisp_Object object = glyph->object;
24816 int charpos = glyph->charpos; 24834 EMACS_INT charpos = glyph->charpos;
24817 24835
24818 /* Try text properties. */ 24836 /* Try text properties. */
24819 if (STRINGP (object) 24837 if (STRINGP (object)
@@ -24828,7 +24846,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
24828 see if the buffer text ``under'' it does. */ 24846 see if the buffer text ``under'' it does. */
24829 struct glyph_row *r 24847 struct glyph_row *r
24830 = MATRIX_ROW (w->current_matrix, vpos); 24848 = MATRIX_ROW (w->current_matrix, vpos);
24831 int start = MATRIX_ROW_START_CHARPOS (r); 24849 EMACS_INT start = MATRIX_ROW_START_CHARPOS (r);
24832 EMACS_INT pos = string_buffer_position (w, object, 24850 EMACS_INT pos = string_buffer_position (w, object,
24833 start); 24851 start);
24834 if (pos > 0) 24852 if (pos > 0)
diff --git a/src/xgselect.c b/src/xgselect.c
index 56e14fe6e14..487f9882b81 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -109,11 +109,17 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
109 if (rfds && FD_ISSET (i, rfds)) ++retval; 109 if (rfds && FD_ISSET (i, rfds)) ++retval;
110 else ++our_fds; 110 else ++our_fds;
111 } 111 }
112 else if (rfds)
113 FD_CLR (i, rfds);
114
112 if (have_wfds && FD_ISSET (i, &all_wfds)) 115 if (have_wfds && FD_ISSET (i, &all_wfds))
113 { 116 {
114 if (wfds && FD_ISSET (i, wfds)) ++retval; 117 if (wfds && FD_ISSET (i, wfds)) ++retval;
115 else ++our_fds; 118 else ++our_fds;
116 } 119 }
120 else if (wfds)
121 FD_CLR (i, wfds);
122
117 if (efds && FD_ISSET (i, efds)) 123 if (efds && FD_ISSET (i, efds))
118 ++retval; 124 ++retval;
119 } 125 }
diff --git a/src/xml.c b/src/xml.c
index c1098b15a20..5829f1da538 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -30,50 +30,55 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30 30
31Lisp_Object make_dom (xmlNode *node) 31Lisp_Object make_dom (xmlNode *node)
32{ 32{
33 if (node->type == XML_ELEMENT_NODE) { 33 if (node->type == XML_ELEMENT_NODE)
34 Lisp_Object result = Fcons (intern (node->name), Qnil); 34 {
35 xmlNode *child; 35 Lisp_Object result = Fcons (intern (node->name), Qnil);
36 xmlAttr *property; 36 xmlNode *child;
37 37 xmlAttr *property;
38 /* First add the attributes. */ 38 Lisp_Object plist = Qnil;
39 property = node->properties; 39
40 while (property != NULL) { 40 /* First add the attributes. */
41 if (property->children && 41 property = node->properties;
42 property->children->content) { 42 while (property != NULL)
43 char *pname = xmalloc (strlen (property->name) + 2); 43 {
44 *pname = ':'; 44 if (property->children &&
45 strcpy(pname + 1, property->name); 45 property->children->content)
46 result = Fcons (Fcons (intern (pname), 46 {
47 build_string(property->children->content)), 47 plist = Fcons (Fcons (intern (property->name),
48 result); 48 build_string (property->children->content)),
49 xfree (pname); 49 plist);
50 } 50 }
51 property = property->next; 51 property = property->next;
52 }
53 result = Fcons (Fnreverse (plist), result);
54
55 /* Then add the children of the node. */
56 child = node->children;
57 while (child != NULL)
58 {
59 result = Fcons (make_dom (child), result);
60 child = child->next;
61 }
62
63 return Fnreverse (result);
52 } 64 }
53 /* Then add the children of the node. */ 65 else if (node->type == XML_TEXT_NODE)
54 child = node->children; 66 {
55 while (child != NULL) { 67 if (node->content)
56 result = Fcons (make_dom (child), result); 68 return build_string (node->content);
57 child = child->next; 69 else
70 return Qnil;
58 } 71 }
59 return Fnreverse (result); 72 else
60 } else if (node->type == XML_TEXT_NODE) {
61 Lisp_Object content = Qnil;
62
63 if (node->content)
64 content = build_string (node->content);
65
66 return Fcons (intern (node->name), content);
67 } else
68 return Qnil; 73 return Qnil;
69} 74}
70 75
71static Lisp_Object 76static Lisp_Object
72parse_buffer (Lisp_Object string, Lisp_Object base_url, int htmlp) 77parse_string (Lisp_Object string, Lisp_Object base_url, int htmlp)
73{ 78{
74 xmlDoc *doc; 79 xmlDoc *doc;
75 xmlNode *node; 80 xmlNode *node;
76 Lisp_Object result; 81 Lisp_Object result = Qnil;
77 int ibeg, iend; 82 int ibeg, iend;
78 char *burl = ""; 83 char *burl = "";
79 84
@@ -81,50 +86,50 @@ parse_buffer (Lisp_Object string, Lisp_Object base_url, int htmlp)
81 86
82 CHECK_STRING (string); 87 CHECK_STRING (string);
83 88
84 if (! NILP (base_url)) { 89 if (! NILP (base_url))
85 CHECK_STRING (base_url); 90 {
86 burl = SDATA (base_url); 91 CHECK_STRING (base_url);
87 } 92 burl = SDATA (base_url);
88 93 }
89 if (htmlp)
90 doc = htmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
91 HTML_PARSE_RECOVER|HTML_PARSE_NONET|
92 HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR);
93 else
94 doc = xmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
95 XML_PARSE_NONET|XML_PARSE_NOWARNING|
96 XML_PARSE_NOERROR);
97
98 if (doc != NULL) {
99 node = xmlDocGetRootElement (doc);
100 if (node != NULL)
101 result = make_dom (node);
102 94
103 xmlFreeDoc (doc); 95 doc = htmlp
104 xmlCleanupParser (); 96 ? htmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
105 } 97 HTML_PARSE_RECOVER|HTML_PARSE_NONET|
98 HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR)
99 : xmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
100 XML_PARSE_NONET|XML_PARSE_NOWARNING|
101 XML_PARSE_NOERROR);
102
103 if (doc != NULL)
104 {
105 node = xmlDocGetRootElement (doc);
106 if (node != NULL)
107 result = make_dom (node);
108 xmlFreeDoc (doc);
109 xmlCleanupParser ();
110 }
106 111
107 return result; 112 return result;
108} 113}
109 114
110DEFUN ("html-parse-string", Fhtml_parse_string, Shtml_parse_string, 115DEFUN ("xml-parse-html-string-internal", Fxml_parse_html_string_internal,
111 0, 2, 0, 116 Sxml_parse_html_string_internal,
112 doc: /* Parse the string as an HTML document and return the parse tree. 117 1, 2, 0,
113If BASE-URL is non-nil, it will be used to expand relative URLs in 118 doc: /* Parse STRING as an HTML document and return the parse tree.
114the HTML document.*/) 119If BASE-URL is non-nil, it is used to expand relative URLs. */)
115 (Lisp_Object string, Lisp_Object base_url) 120 (Lisp_Object string, Lisp_Object base_url)
116{ 121{
117 return parse_buffer (string, base_url, 1); 122 return parse_string (string, base_url, 1);
118} 123}
119 124
120DEFUN ("xml-parse-string", Fxml_parse_string, Sxml_parse_string, 125DEFUN ("xml-parse-string-internal", Fxml_parse_string_internal,
121 0, 2, 0, 126 Sxml_parse_string_internal,
122 doc: /* Parse the string as an XML document and return the parse tree. 127 1, 2, 0,
123If BASE-URL is non-nil, it will be used to expand relative URLs in 128 doc: /* Parse STRING as an XML document and return the parse tree.
124the XML document.*/) 129If BASE-URL is non-nil, it is used to expand relative URLs. */)
125 (Lisp_Object string, Lisp_Object base_url) 130 (Lisp_Object string, Lisp_Object base_url)
126{ 131{
127 return parse_buffer (string, base_url, 0); 132 return parse_string (string, base_url, 0);
128} 133}
129 134
130 135
@@ -134,8 +139,8 @@ the XML document.*/)
134void 139void
135syms_of_xml (void) 140syms_of_xml (void)
136{ 141{
137 defsubr (&Shtml_parse_string); 142 defsubr (&Sxml_parse_html_string_internal);
138 defsubr (&Sxml_parse_string); 143 defsubr (&Sxml_parse_string_internal);
139} 144}
140 145
141#endif /* HAVE_LIBXML2 */ 146#endif /* HAVE_LIBXML2 */
diff --git a/src/xrdb.c b/src/xrdb.c
index d81f08747ac..d2898e1d8f8 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -127,7 +127,7 @@ x_get_customization_string (XrmDatabase db, const char *name, const char *class)
127 Return NULL otherwise. */ 127 Return NULL otherwise. */
128 128
129static char * 129static char *
130magic_file_p (const char *string, int string_len, const char *class, const char *escaped_suffix, const char *suffix) 130magic_file_p (const char *string, EMACS_INT string_len, const char *class, const char *escaped_suffix, const char *suffix)
131{ 131{
132 char *lang = getenv ("LANG"); 132 char *lang = getenv ("LANG");
133 133
diff --git a/src/xterm.c b/src/xterm.c
index 2ebe8a80378..f9dd21c87fe 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4004,7 +4004,7 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name,
4004 XEvent *event, String *params, Cardinal *num_params) 4004 XEvent *event, String *params, Cardinal *num_params)
4005{ 4005{
4006 int scroll_bar_p; 4006 int scroll_bar_p;
4007 char *end_action; 4007 const char *end_action;
4008 4008
4009#ifdef USE_MOTIF 4009#ifdef USE_MOTIF
4010 scroll_bar_p = XmIsScrollBar (widget); 4010 scroll_bar_p = XmIsScrollBar (widget);
@@ -8285,19 +8285,89 @@ x_set_sticky (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
8285 "_NET_WM_STATE_STICKY", NULL); 8285 "_NET_WM_STATE_STICKY", NULL);
8286} 8286}
8287 8287
8288/* Return the current _NET_WM_STATE.
8289 SIZE_STATE is set to one of the FULLSCREEN_* values.
8290 STICKY is set to 1 if the sticky state is set, 0 if not. */
8291
8292static void
8293get_current_vm_state (struct frame *f,
8294 Window window,
8295 int *size_state,
8296 int *sticky)
8297{
8298 Atom actual_type;
8299 unsigned long actual_size, bytes_remaining;
8300 int i, rc, actual_format;
8301 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
8302 long max_len = 65536;
8303 Display *dpy = FRAME_X_DISPLAY (f);
8304 unsigned char *tmp_data = NULL;
8305 Atom target_type = XA_ATOM;
8306
8307 *sticky = 0;
8308 *size_state = FULLSCREEN_NONE;
8309
8310 BLOCK_INPUT;
8311 x_catch_errors (dpy);
8312 rc = XGetWindowProperty (dpy, window, dpyinfo->Xatom_net_wm_state,
8313 0, max_len, False, target_type,
8314 &actual_type, &actual_format, &actual_size,
8315 &bytes_remaining, &tmp_data);
8316
8317 if (rc != Success || actual_type != target_type || x_had_errors_p (dpy))
8318 {
8319 if (tmp_data) XFree (tmp_data);
8320 x_uncatch_errors ();
8321 UNBLOCK_INPUT;
8322 return;
8323 }
8324
8325 x_uncatch_errors ();
8326
8327 for (i = 0; i < actual_size; ++i)
8328 {
8329 Atom a = ((Atom*)tmp_data)[i];
8330 if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
8331 {
8332 if (*size_state == FULLSCREEN_HEIGHT)
8333 *size_state = FULLSCREEN_MAXIMIZED;
8334 else
8335 *size_state = FULLSCREEN_WIDTH;
8336 }
8337 else if (a == dpyinfo->Xatom_net_wm_state_maximized_vert)
8338 {
8339 if (*size_state == FULLSCREEN_WIDTH)
8340 *size_state = FULLSCREEN_MAXIMIZED;
8341 else
8342 *size_state = FULLSCREEN_HEIGHT;
8343 }
8344 else if (a == dpyinfo->Xatom_net_wm_state_fullscreen_atom)
8345 *size_state = FULLSCREEN_BOTH;
8346 else if (a == dpyinfo->Xatom_net_wm_state_sticky)
8347 *sticky = 1;
8348 }
8349
8350 if (tmp_data) XFree (tmp_data);
8351 UNBLOCK_INPUT;
8352}
8353
8288/* Do fullscreen as specified in extended window manager hints */ 8354/* Do fullscreen as specified in extended window manager hints */
8289 8355
8290static int 8356static int
8291do_ewmh_fullscreen (struct frame *f) 8357do_ewmh_fullscreen (struct frame *f)
8292{ 8358{
8293 int have_net_atom = wm_supports (f, "_NET_WM_STATE"); 8359 int have_net_atom = wm_supports (f, "_NET_WM_STATE");
8360 Lisp_Object lval = get_frame_param (f, Qfullscreen);
8361 int cur, dummy;
8362
8363 get_current_vm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
8294 8364
8295 /* Some window managers don't say they support _NET_WM_STATE, but they do say 8365 /* Some window managers don't say they support _NET_WM_STATE, but they do say
8296 they support _NET_WM_STATE_FULLSCREEN. Try that also. */ 8366 they support _NET_WM_STATE_FULLSCREEN. Try that also. */
8297 if (!have_net_atom) 8367 if (!have_net_atom)
8298 have_net_atom = wm_supports (f, "_NET_WM_STATE_FULLSCREEN"); 8368 have_net_atom = wm_supports (f, "_NET_WM_STATE_FULLSCREEN");
8299 8369
8300 if (have_net_atom) 8370 if (have_net_atom && cur != f->want_fullscreen)
8301 { 8371 {
8302 Lisp_Object frame; 8372 Lisp_Object frame;
8303 const char *fs = "_NET_WM_STATE_FULLSCREEN"; 8373 const char *fs = "_NET_WM_STATE_FULLSCREEN";
@@ -8306,26 +8376,41 @@ do_ewmh_fullscreen (struct frame *f)
8306 8376
8307 XSETFRAME (frame, f); 8377 XSETFRAME (frame, f);
8308 8378
8309 set_wm_state (frame, 0, fs, NULL); 8379 /* Keep number of calls to set_wm_state as low as possible.
8310 set_wm_state (frame, 0, fh, NULL); 8380 Some window managers, or possible Gtk+, hangs when too many
8311 set_wm_state (frame, 0, fw, NULL); 8381 are sent at once. */
8312
8313 /* If there are _NET_ atoms we assume we have extended window manager
8314 hints. */
8315 switch (f->want_fullscreen) 8382 switch (f->want_fullscreen)
8316 { 8383 {
8317 case FULLSCREEN_BOTH: 8384 case FULLSCREEN_BOTH:
8385 if (cur == FULLSCREEN_WIDTH || cur == FULLSCREEN_MAXIMIZED
8386 || cur == FULLSCREEN_HEIGHT)
8387 set_wm_state (frame, 0, fw, fh);
8318 set_wm_state (frame, 1, fs, NULL); 8388 set_wm_state (frame, 1, fs, NULL);
8319 break; 8389 break;
8320 case FULLSCREEN_WIDTH: 8390 case FULLSCREEN_WIDTH:
8321 set_wm_state (frame, 1, fw, NULL); 8391 if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_HEIGHT
8392 || cur == FULLSCREEN_MAXIMIZED)
8393 set_wm_state (frame, 0, fs, fh);
8394 if (cur != FULLSCREEN_MAXIMIZED)
8395 set_wm_state (frame, 1, fw, NULL);
8322 break; 8396 break;
8323 case FULLSCREEN_HEIGHT: 8397 case FULLSCREEN_HEIGHT:
8324 set_wm_state (frame, 1, fh, NULL); 8398 if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_WIDTH
8399 || cur == FULLSCREEN_MAXIMIZED)
8400 set_wm_state (frame, 0, fs, fw);
8401 if (cur != FULLSCREEN_MAXIMIZED)
8402 set_wm_state (frame, 1, fh, NULL);
8325 break; 8403 break;
8326 case FULLSCREEN_MAXIMIZED: 8404 case FULLSCREEN_MAXIMIZED:
8405 if (cur == FULLSCREEN_BOTH)
8406 set_wm_state (frame, 0, fs, NULL);
8327 set_wm_state (frame, 1, fw, fh); 8407 set_wm_state (frame, 1, fw, fh);
8328 break; 8408 break;
8409 case FULLSCREEN_NONE:
8410 if (cur == FULLSCREEN_BOTH)
8411 set_wm_state (frame, 0, fs, NULL);
8412 else
8413 set_wm_state (frame, 0, fw, fh);
8329 } 8414 }
8330 8415
8331 f->want_fullscreen = FULLSCREEN_NONE; 8416 f->want_fullscreen = FULLSCREEN_NONE;
@@ -8351,57 +8436,11 @@ XTfullscreen_hook (FRAME_PTR f)
8351static void 8436static void
8352x_handle_net_wm_state (struct frame *f, XPropertyEvent *event) 8437x_handle_net_wm_state (struct frame *f, XPropertyEvent *event)
8353{ 8438{
8354 Atom actual_type; 8439 int value = FULLSCREEN_NONE;
8355 unsigned long actual_size, bytes_remaining;
8356 int i, rc, actual_format, value = FULLSCREEN_NONE;
8357 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
8358 long max_len = 65536;
8359 Display *dpy = FRAME_X_DISPLAY (f);
8360 unsigned char *tmp_data = NULL;
8361 Atom target_type = XA_ATOM;
8362 Lisp_Object lval; 8440 Lisp_Object lval;
8363 int sticky = 0; 8441 int sticky = 0;
8364 8442
8365 BLOCK_INPUT; 8443 get_current_vm_state (f, event->window, &value, &sticky);
8366 x_catch_errors (dpy);
8367 rc = XGetWindowProperty (dpy, event->window,
8368 event->atom, 0, max_len, False, target_type,
8369 &actual_type, &actual_format, &actual_size,
8370 &bytes_remaining, &tmp_data);
8371
8372 if (rc != Success || actual_type != target_type || x_had_errors_p (dpy))
8373 {
8374 if (tmp_data) XFree (tmp_data);
8375 x_uncatch_errors ();
8376 UNBLOCK_INPUT;
8377 return;
8378 }
8379
8380 x_uncatch_errors ();
8381
8382 for (i = 0; i < actual_size; ++i)
8383 {
8384 Atom a = ((Atom*)tmp_data)[i];
8385 if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
8386 {
8387 if (value == FULLSCREEN_HEIGHT)
8388 value = FULLSCREEN_MAXIMIZED;
8389 else
8390 value = FULLSCREEN_WIDTH;
8391 }
8392 else if (a == dpyinfo->Xatom_net_wm_state_maximized_vert)
8393 {
8394 if (value == FULLSCREEN_WIDTH)
8395 value = FULLSCREEN_MAXIMIZED;
8396 else
8397 value = FULLSCREEN_HEIGHT;
8398 }
8399 else if (a == dpyinfo->Xatom_net_wm_state_fullscreen_atom)
8400 value = FULLSCREEN_BOTH;
8401 else if (a == dpyinfo->Xatom_net_wm_state_sticky)
8402 sticky = 1;
8403 }
8404
8405 lval = Qnil; 8444 lval = Qnil;
8406 switch (value) 8445 switch (value)
8407 { 8446 {
@@ -8421,9 +8460,6 @@ x_handle_net_wm_state (struct frame *f, XPropertyEvent *event)
8421 8460
8422 store_frame_param (f, Qfullscreen, lval); 8461 store_frame_param (f, Qfullscreen, lval);
8423 store_frame_param (f, Qsticky, sticky ? Qt : Qnil); 8462 store_frame_param (f, Qsticky, sticky ? Qt : Qnil);
8424
8425 if (tmp_data) XFree (tmp_data);
8426 UNBLOCK_INPUT;
8427} 8463}
8428 8464
8429/* Check if we need to resize the frame due to a fullscreen request. 8465/* Check if we need to resize the frame due to a fullscreen request.