aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2010-09-27 14:42:43 +0900
committerKenichi Handa2010-09-27 14:42:43 +0900
commitb3253cd4b4bcbe1ab4ad1fdc98b30c33af70332c (patch)
tree4d55005558f96dfb44bfcd746098ed0882aff2d0 /src
parent4be9765d4bad14d68cdfee2a2c6afe1001d9516a (diff)
parente5fa38990bca723fc3ef1d0ede792e8ff84b84f7 (diff)
downloademacs-b3253cd4b4bcbe1ab4ad1fdc98b30c33af70332c.tar.gz
emacs-b3253cd4b4bcbe1ab4ad1fdc98b30c33af70332c.zip
merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog514
-rw-r--r--src/ChangeLog.52
-rw-r--r--src/ChangeLog.72
-rw-r--r--src/Makefile.in7
-rw-r--r--src/alloc.c92
-rw-r--r--src/bidi.c12
-rw-r--r--src/buffer.c95
-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/cmds.c31
-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.c170
-rw-r--r--src/dispextern.h17
-rw-r--r--src/dispnew.c17
-rw-r--r--src/doc.c38
-rw-r--r--src/doprnt.c4
-rw-r--r--src/editfns.c139
-rw-r--r--src/emacs.c8
-rw-r--r--src/eval.c10
-rw-r--r--src/fns.c139
-rw-r--r--src/font.c2
-rw-r--r--src/frame.h2
-rw-r--r--src/gnutls.c551
-rw-r--r--src/gnutls.h60
-rw-r--r--src/gtkutil.c2
-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.c68
-rw-r--r--src/keyboard.h2
-rw-r--r--src/lisp.h91
-rw-r--r--src/lread.c20
-rw-r--r--src/marker.c70
-rw-r--r--src/minibuf.c10
-rw-r--r--src/print.c51
-rw-r--r--src/process.c277
-rw-r--r--src/process.h22
-rw-r--r--src/region-cache.c83
-rw-r--r--src/region-cache.h12
-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.c157
-rw-r--r--src/termhooks.h6
-rw-r--r--src/textprop.c42
-rw-r--r--src/undo.c16
-rw-r--r--src/w32.c45
-rw-r--r--src/w32fns.c4
-rw-r--r--src/window.c26
-rw-r--r--src/xdisp.c82
-rw-r--r--src/xml.c129
-rw-r--r--src/xrdb.c2
63 files changed, 2554 insertions, 1129 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7f35c67039c..84730fede8a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -24,6 +24,516 @@
24 (append_glyph, produce_image_glyph, append_stretch_glyph) 24 (append_glyph, produce_image_glyph, append_stretch_glyph)
25 (note_mouse_highlight): Likewise. 25 (note_mouse_highlight): Likewise.
26 26
272010-09-26 Jan Djärv <jan.h.d@swipnet.se>
28
29 * process.c (add_keyboard_wait_descriptor)
30 (delete_keyboard_wait_descriptor): Reinstate ifdef subprocesses.
31 (wait_reading_process_output): Don't pass write_mask to select
32 if SELECT_CANT_DO_WRITE_MASK is defined.
33 (SELECT_CANT_DO_WRITE_MASK): Define if SELECT_CANT_DO_WRITE_MASK.
34
35 * process.h (add_read_fd, delete_read_fd, add_write_fd)
36 (delete_write_fd): Declare.
37
38 * process.c (gpm_wait_mask, max_gpm_desc): Remove.
39 (write_mask): New variable.
40 (max_input_desc): Renamed from max_keyboard_desc.
41 (fd_callback_info): New variable.
42 (add_read_fd, delete_read_fd, add_write_fd, delete_write_fd): New
43 functions.
44 (Fmake_network_process): FD_SET write_mask.
45 (deactivate_process): FD_CLR write_mask.
46 (wait_reading_process_output): Connecting renamed to Writeok.
47 check_connect removed. check_write is new. Remove references to
48 gpm. Use Writeok/check_write unconditionally (i.e. no #ifdef
49 NON_BLOCKING_CONNECT) instead of Connecting.
50 Loop over file descriptors and call callbacks in fd_callback_info
51 if file descriptor is ready for I/O.
52 (add_gpm_wait_descriptor): Just call add_keyboard_wait_descriptor.
53 (delete_gpm_wait_descriptor): Just call delete_keyboard_wait_descriptor.
54 (keyboard_bit_set): Use max_input_desc.
55 (add_keyboard_wait_descriptor, delete_keyboard_wait_descriptor): Remove
56 #ifdef subprocesses. Use max_input_desc.
57 (init_process): Initialize write_mask and fd_callback_info.
58
59 * keyboard.c (readable_events, gobble_input): Remove DBUS code.
60
61 * dbusbind.c: Include process.h.
62 (dbus_fd_cb, xd_find_watch_fd, xd_toggle_watch)
63 (xd_read_message_1): New functions.
64 (xd_add_watch, xd_remove_watch): Call xd_find_watch_fd. Handle
65 watch for both read and write.
66 (Fdbus_init_bus): Also register xd_toggle_watch.
67 (Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
68 (Fdbus_method_error_internal, Fdbus_send_signal): Remove call
69 to dbus_connection_flush.
70 (xd_read_message): Move most of the code to xd_read_message_1.
71 Call xd_read_message_1 until status is COMPLETE.
72
732010-09-26 Dan Nicolaescu <dann@ics.uci.edu>
74
75 * term.c: Do not include sys/ioctl.h, not needed.
76 (init_tty): Reorder code to reduce the number of #ifdefs. No code
77 changes.
78
792010-09-26 Teodor Zlatanov <tzz@lifelogs.com>
80
81 * process.h: Set up GnuTLS support.
82
83 * process.c (make_process, Fstart_process)
84 (read_process_output, send_process): Set up GnuTLS support for
85 process input/output file descriptors.
86
87 * gnutls.h: The GnuTLS glue for Emacs, macros and enums.
88
89 * gnutls.c: The source code for GnuTLS support in Emacs.
90
91 * emacs.c: Set up GnuTLS support and call syms_of_gnutls.
92
93 * config.in: Set up GnuTLS support.
94
95 * Makefile.in (LIBGNUTLS_LIBS, LIBGNUTLS_CFLAGS, ALL_CFLAGS)
96 (obj, LIBES): Set up GnuTLS support.
97
982010-09-26 Juanma Barranquero <lekktu@gmail.com>
99
100 * w32.c (get_emacs_configuration_options): Fix previous change.
101
1022010-09-25 Chong Yidong <cyd@stupidchicken.com>
103
104 * insdel.c (prepare_to_modify_buffer): Ensure the mark marker is
105 alive before using it (Bug#6977).
106
1072010-09-25 Lars Magne Ingebrigtsen <larsi@gnus.org>
108
109 * xdisp.c (face_before_or_after_it_pos): EMACS_INT/int fixup.
110
111 * dispextern.h: EMACS_INT/int fixup.
112
113 * xdisp.c (string_pos_nchars_ahead, init_iterator): EMACS_INT/int
114 fixup.
115
116 * xrdb.c (magic_file_p): EMACS_INT/int fixup.
117
1182010-09-25 Eli Zaretskii <eliz@gnu.org>
119
120 * window.c (Fpos_visible_in_window_p, Fdelete_other_windows)
121 (Fselect_window, window_scroll_pixel_based)
122 (window_scroll_line_based, Frecenter, Fset_window_configuration):
123 Use EMACS_INT for buffer positions.
124
125 * textprop.c (validate_interval_range, interval_of)
126 (property_change_between_p, Fadd_text_properties)
127 (set_text_properties_1, Fremove_text_properties)
128 (Fremove_list_of_text_properties, Ftext_property_any)
129 (Ftext_property_not_all, copy_text_properties)
130 (text_property_list, extend_property_ranges)
131 (verify_interval_modification): Use EMACS_INT for buffer
132 positions.
133
134 * term.c (fast_find_position, term_mouse_highlight): Use EMACS_INT
135 for buffer positions.
136
137 * process.c (read_process_output, send_process)
138 (Fprocess_send_region, status_notify): Use EMACS_INT for buffer
139 and string positions and size.
140
141 * print.c (print_object, print_string, strout): Use EMACS_INT for
142 string indices.
143
144 * minibuf.c (string_to_object): Use EMACS_INT for string position
145 and size.
146
147 * marker.c (verify_bytepos): Use EMACS_INT for buffer positions.
148
149 * lread.c <read_from_string_index, read_from_string_index_byte>
150 <read_from_string_limit, readchar_count>: Define EMACS_INT.
151 (readchar, unreadchar, read_internal_start): Use EMACS_INT for
152 buffer positions and string length.
153
154 * keyboard.c <last_point_position, last_non_minibuf_size>: Declare
155 EMACS_INT.
156 (echo_truncate, adjust_point_for_property, read_char)
157 (gen_help_event, make_lispy_event, modify_event_symbol)
158 (Fexecute_extended_command, stuff_buffered_input): Use EMACS_INT
159 for buffer positions and string length.
160
161 * keyboard.h (gen_help_event): Adjust prototype.
162
163 * termhooks.h <struct input_event>: Make `code' member EMACS_INT.
164
165 * commands.h <last_point_position>: Declare EMACS_INT.
166
167 * xdisp.c <help_echo_pos>: Define as EMACS_INT.
168 (truncate_echo_area): Accept EMACS_INT argument.
169
170 * dispextern.h <help_echo_pos>: Declare EMACS_INT.
171
172 * lisp.h (truncate_echo_area): Adjust prototype.
173
174 * composite.c (composition_adjust_point): Return EMACS_INT.
175
176 * composite.h (composition_adjust_point): Adjust prototype.
177
1782010-09-25 Juanma Barranquero <lekktu@gmail.com>
179
180 * process.c (Fmake_network_process): When arg :host is 'local,
181 use address 127.0.0.1, not name "localhost". (Bug#6781)
182
1832010-09-24 Eli Zaretskii <eliz@gnu.org>
184
185 * indent.c (Fcurrent_indentation, indented_beyond_p)
186 (compute_motion): Use EMACS_INT for buffer position variables.
187
188 * lisp.h (indented_beyond_p): Adjust prototype.
189
190 * buffer.c (overlay_strings): Return EMACS_INT.
191
192 * buffer.h (overlay_strings): Adjust prototype.
193
194 * region-cache.c (pp_cache): Adjust format to arguments.
195
196 * eval.c <specpdl_size, lisp_eval_depth>: Declare EMACS_INT.
197 (call_debugger): Use EMACS_INT for specpdl_size related variables.
198 (verror): Use EMACS_INT for size of allocated buffer.
199
200 * keyboard.c (make_lispy_position): Use EMACS_INT for buffer
201 positions.
202
203 * xdisp.c (redisplay_internal, try_window_id)
204 (set_cursor_from_row, find_first_unchanged_at_end_row): Use
205 EMACS_INT for buffer positions.
206
207 * dispextern.h (set_cursor_from_row): Adjust prototype.
208
209 * dispnew.c (increment_matrix_positions)
210 (increment_row_positions, copy_glyph_row_contents)
211 (mode_line_string, marginal_area_string): Use EMACS_INT for buffer
212 positions.
213
214 * dispextern.h (mode_line_string, marginal_area_string)
215 (increment_matrix_positions, increment_row_positions): Adjust
216 prototypes.
217
218 * data.c (Faref, Faset): Use EMACS_INT for string length and
219 positions.
220
221 * cmds.c (internal_self_insert): Use EMACS_INT for the count of
222 characters to insert.
223
224 * ccl.c (Fccl_execute_on_string): Use EMACS_INT for string
225 position and size.
226
227 * syntax.c (scan_words, update_syntax_table)
228 (prev_char_comend_first, back_comment, skip_chars)
229 (skip_syntaxes, Fforward_comment, Fbackward_prefix_chars): Use
230 EMACS_INT for buffer and string positions.
231
232 * syntax.h (scan_words, update_syntax_table): Adjust prototypes.
233
234 * casefiddle.c (operate_on_word): Use EMACS_INT for buffer
235 positions.
236
2372010-09-24 Lars Magne Ingebrigtsen <larsi@gnus.org>
238
239 * scroll.c (calculate_scrolling, line_ins_del)
240 (calculate_direct_scrolling, scroll_cost): Fix EMACS_INT/int
241 conversion.
242
243 * region-cache.c (move_cache_gap, set_cache_region, pp_cache)
244 (region_cache_backward, region_cache_forward)
245 (revalidate_region_cache, set_cache_region): FIX EMACS_INT/int
246 conversion.
247
248 * xdisp.c (message_dolog): Fix EMACS_INT/int conversion.
249
250 * eval.c (verror): Fix EMACS_INT/int conversion.
251
252 * print.c (PRINTDECLARE, PRINTPREPARE, strout, print_string)
253 (print_preprocess, print_check_string_charset_prop)
254 (print_object): Fix EMACS_INT/int conversion.
255
256 * xdisp.c (message_dolog): Fix EMACS_INT/int conversion.
257
2582010-09-24 Eli Zaretskii <eliz@gnu.org>
259
260 * callproc.c (Fcall_process): Use EMACS_INT for count of
261 characters read from the subprocess.
262
263 * bidi.c (struct bidi_paragraph_info): Use EMACS_INT for buffer
264 positions.
265 (bidi_cache_search, bidi_cache_find): Use EMACS_INT for buffer
266 positions.
267
268 * buffer.c (struct sortvec): Use EMACS_INT for buffer positions.
269 (struct sortstrlist, overlay_str_len): Use EMACS_INT for string
270 length.
271 (advance_to_char_boundary, Fset_buffer_multibyte)
272 (overlays_at, overlays_in, mouse_face_overlay_overlaps)
273 (overlay_touches_p, record_overlay_string, overlay_strings)
274 (recenter_overlay_lists, fix_start_end_in_overlays)
275 (modify_overlay, Fmove_overlay, report_overlay_modification)
276 (evaporate_overlays): Use EMACS_INT for buffer positions.
277
278 * lisp.h (fix_start_end_in_overlays, overlay_touches_p): Adjust
279 prototypes.
280
281 * dispextern.h (struct bidi_saved_info): Use EMACS_INT for buffer
282 positions.
283
284 * fns.c (Fcompare_strings, Fstring_lessp, concat)
285 (string_make_unibyte, Fstring_as_unibyte, Fsubstring)
286 (Fsubstring_no_properties, substring_both, Ffillarray)
287 (Fclear_string, mapcar1, Fmapconcat, Fmapcar, Fmapc)
288 (Fbase64_encode_region, Fbase64_encode_string, base64_encode_1)
289 (Fbase64_decode_region, Fbase64_decode_string, base64_decode_1)
290 (Fmd5): Use EMACS_INT for buffer and string positions and length
291 variables and arguments.
292
293 * lisp.h (substring_both): Adjust prototype.
294
2952010-09-24 Juanma Barranquero <lekktu@gmail.com>
296
297 Remove W32 API function pointer unused since 2005-02-15 (revno 2005-02-15T23:19:26Z!jasonr@gnu.org).
298 * w32fns.c (clipboard_sequence_fn): Don't declare.
299 (globals_of_w32fns): Don't initialize it.
300
3012010-09-23 Stefan Monnier <monnier@iro.umontreal.ca>
302
303 * syntax.c (back_comment): Detect the case where a 1-char comment
304 starter is also the 2nd char of a 2-char comment ender.
305
3062010-09-23 Jan Djärv <jan.h.d@swipnet.se>
307
308 * gtkutil.c (xg_tool_bar_menu_proxy): Set gtk-menu-items to TRUE.
309
3102010-09-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
311
312 * eval.c (verror): EMACS_INT/int cleanup.
313
314 * lisp.h (SPECPDL_INDEX): Cast to int, since we're not going to
315 unwind_protect more than 2GB worth of functions.
316
317 * editfns.c (Finsert_char): EMACS_INT/int cleanup.
318
319 * lisp.h: Have oblookup take EMACS_INT to allow interning big
320 string and avoid compiler warnings.
321 (USE_SAFE_ALLOCA): Cast to int to avoid compilation warnings in
322 all users.
323
324 * lread.c (oblookup): EMACS_INT/int cleanup.
325
326 * cmds.c (Fforward_line, Fdelete_char): EMACS_INT/int cleanup.
327
3282010-09-23 Eli Zaretskii <eliz@gnu.org>
329
330 * editfns.c (clip_to_bounds): Return an EMACS_INT value.
331
332 * lisp.h (clip_to_bounds): Adjust prototype.
333
334 * intervals.c (adjust_for_invis_intang): Return EMACS_INT value.
335
3362010-09-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
337
338 * lisp.h: doprnt.c EMACS_INT/int cleanup.
339
340 * doprnt.c (doprnt): EMACS_INT/int cleanup.
341
342 * doc.c (Fsnarf_documentation, get_doc_string): EMACS_INT/int
343 cleanup.
344
345 * lisp.h: Change the definition of all marker.c functions that
346 take and return buffer stuff to be EMACS_INT instead of int.
347
348 * marker.c (buf_charpos_to_bytepos, CONSIDER, set_marker_both)
349 (buf_charpos_to_bytepos, bytepos_to_charpos)
350 (buf_bytepos_to_charpos, Fbuffer_has_markers_at)
351 (set_marker_restricted, set_marker_both): Convert int to EMACS_INT
352 for all buffer positions.
353
3542010-09-23 Chong Yidong <cyd@stupidchicken.com>
355
356 * intervals.c (traverse_intervals, rotate_right, rotate_left)
357 (split_interval_right, find_interval, next_interval)
358 (delete_node, delete_interval, interval_deletion_adjustment)
359 (adjust_intervals_for_deletion, merge_interval_right)
360 (merge_interval_left, graft_intervals_into_buffer)
361 (copy_intervals): Convert EMACS_UINTs to EMACS_INT.
362
363 * intervals.h (traverse_intervals): Update prototype.
364
3652010-09-23 Eli Zaretskii <eliz@gnu.org>
366
367 * indent.c (compute_motion): Use EMACS_INT for arguments to
368 region_cache_forward.
369
370 * region-cache.c (struct boundary, struct region_cache): Use
371 EMACS_INT for positions.
372 (find_cache_boundary, move_cache_gap, insert_cache_boundary)
373 (delete_cache_boundaries, set_cache_region)
374 (invalidate_region_cache, know_region_cache)
375 (region_cache_forward, region_cache_backward, pp_cache): Use
376 EMACS_INT for buffer positions.
377
378 * region-cache.h (know_region_cache, invalidate_region_cache)
379 (region_cache_forward, region_cache_backward): Adjust prototypes.
380
381 * search.c (string_match_1, fast_c_string_match_ignore_case)
382 (looking_at_1, scan_buffer, scan_newline)
383 (find_next_newline_no_quit, find_before_next_newline)
384 (search_command, trivial_regexp_p, search_buffer, simple_search)
385 (boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer
386 and string positions and length.
387
388 * lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit)
389 (find_before_next_newline): Adjust prototypes.
390
391 * editfns.c (transpose_markers, update_buffer_properties)
392 (buildmark, clip_to_bounds, Fgoto_char, overlays_around)
393 (get_pos_property, Fconstrain_to_field)
394 (Fline_beginning_position, Fline_end_position, Fprevious_char)
395 (Fchar_after, Fchar_before, Finsert_char)
396 (Finsert_buffer_substring, Fcompare_buffer_substrings)
397 (Fsubst_char_in_region, Fformat, Ftranspose_regions): Use
398 EMACS_INT for buffer and string position variables.
399 (Finsert_char): Protect against too large insertions.
400
401 * lisp.h (clip_to_bounds): Adjust prototype.
402
403 * intervals.c (traverse_intervals, rotate_right, rotate_left)
404 (balance_an_interval, split_interval_right, split_interval_left)
405 (find_interval, next_interval, update_interval)
406 (adjust_intervals_for_insertion, delete_node, delete_interval)
407 (interval_deletion_adjustment, adjust_intervals_for_deletion)
408 (offset_intervals, merge_interval_right, merge_interval_left)
409 (graft_intervals_into_buffer, adjust_for_invis_intang)
410 (move_if_not_intangible, get_local_map, copy_intervals)
411 (copy_intervals_to_string, compare_string_intervals)
412 (set_intervals_multibyte_1): Use EMACS_INT for buffer positions
413 and for interval tree size.
414
415 * intervals.h (traverse_intervals, split_interval_right)
416 (split_interval_left, find_interval, offset_intervals)
417 (graft_intervals_into_buffer, copy_intervals)
418 (copy_intervals_to_string, move_if_not_intangible, get_local_map)
419 (update_interval): Adjust prototypes.
420
421 * xdisp.c (check_point_in_composition, reconsider_clip_changes):
422 Use EMACS_INT for buffer position variables and arguments.
423
424 * composite.c (get_composition_id, find_composition)
425 (run_composition_function, compose_text)
426 (composition_gstring_width, autocmp_chars)
427 (composition_update_it, Ffind_composition_internal): Use EMACS_INT
428 for buffer positions and string length variables and arguments.
429
430 * composite.h (get_composition_id, find_composition, compose_text)
431 (composition_gstring_width): Adjust prototypes.
432
433 * editfns.c (Fformat): Use EMACS_INT for string size variables.
434
435 * xdisp.c (store_mode_line_noprop, display_mode_element): Use
436 EMACS_INT for string positions.
437
438 * intervals.c (get_property_and_range): Use EMACS_INT for buffer
439 position arguments.
440
441 * intervals.h (get_property_and_range): Adjust prototype.
442
443 * character.c (parse_str_as_multibyte, str_as_multibyte)
444 (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte)
445 (string_count_byte8, string_escape_byte8, c_string_width)
446 (strwidth, lisp_string_width, multibyte_chars_in_text): Use
447 EMACS_INT for string length variables and arguments.
448
449 * character.h (parse_str_as_multibyte, str_as_multibyte)
450 (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte)
451 (c_string_width, strwidth, lisp_string_width): Adjust
452 prototypes.
453
454 * font.c (font_intern_prop): Use EMACS_INT for string length
455 variables.
456
457 * font.c (font_intern_prop): Use EMACS_INT for string length
458 variables.
459
460 * fns.c (Fstring_as_multibyte): Use EMACS_INT for string length
461 variables.
462
463 * alloc.c <total_string_size>: Declare as EMACS_INT, not int.
464 (Fmake_string): Protect against too large strings.
465 (live_string_p, live_cons_p, live_symbol_p, live_float_p)
466 (live_misc_p): Use ptrdiff_t instead of int for pointer
467 differences.
468 (string_bytes, check_sblock, check_string_free_list)
469 (allocate_string_data, compact_small_strings, Fmake_string)
470 (Fmake_bool_vector, make_string, make_unibyte_string)
471 (make_multibyte_string, make_string_from_bytes)
472 (make_specified_string_string, Fmake_list, Fmake_vector): Use
473 EMACS_INT for string length variables and arguments.
474 (find_string_data_in_pure, make_pure_string, make_pure_c_string)
475 (Fpurecopy): Use EMACS_INT for string size.
476 (mark_vectorlike, mark_char_table, mark_object): Use EMACS_UINT
477 for vector size.
478
479 * lisp.h (make_string, make_unibyte_string, make_multibyte_string)
480 (make_string_from_bytes, make_specified_string_string)
481 (make_pure_string, string_bytes, check_point_in_composition):
482 Adjust prototypes.
483
4842010-09-22 Eli Zaretskii <eliz@gnu.org>
485
486 * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal)
487 (check_translation): Use EMACS_INT for buffer positions and
488 length.
489
490 * undo.c (record_marker_adjustment, record_delete)
491 (record_change, record_point, record_insert)
492 (record_property_change, Fprimitive_undo): Use EMACS_INT for
493 buffer positions.
494
495 * lisp.h (record_marker_adjustment, record_delete)
496 (record_change, record_point, record_insert)
497 (record_property_change, Fprimitive_undo): Adjust prototypes.
498
4992010-09-22 Juanma Barranquero <lekktu@gmail.com>
500 Eli Zaretskii <eliz@gnu.org>
501
502 * w32.c (get_emacs_configuration_options): Fix buffer overrun.
503
5042010-09-22 Eli Zaretskii <eliz@gnu.org>
505
506 * minibuf.c (Fminibuffer_contents)
507 (Fminibuffer_contents_no_properties)
508 (Fminibuffer_completion_contents): Use EMACS_INT for minibuffer
509 positions.
510
511 * keyboard.c (command_loop_1): Use EMACS_INT to compare point with
512 mark.
513
514 * alloc.c (make_uninit_string, make_uninit_multibyte_string)
515 (allocate_string_data): Accept EMACS_INT for string length.
516
517 * editfns.c (Ffield_string, Ffield_string_no_properties)
518 (make_buffer_string, make_buffer_string_both, Fbuffer_substring)
519 (Fbuffer_substring_no_properties, find_field, Fdelete_field)
520 (Ffield_string, Ffield_string_no_properties, Ffield_beginning)
521 (Ffield_end): Use EMACS_INT for buffer positions.
522
523 * insdel.c (prepare_to_modify_buffer): Use EMACS_INT to compare
524 point with mark.
525
526 * lisp.h (allocate_string_data, make_uninit_string)
527 (make_uninit_multibyte_string, make_buffer_string)
528 (make_buffer_string_both): Adjust prototypes.
529
5302010-09-22 Chong Yidong <cyd@stupidchicken.com>
531
532 * xml.c: Switch to GNU indentation.
533 (make_dom): Change parse tree format to match xml.el.
534 (Fxml_parse_html_string_internal): Rename from html-parse-string.
535 (Fxml_parse_string_internal): Rename from xml-parse-string.
536
272010-09-22 Kenichi Handa <handa@m17n.org> 5372010-09-22 Kenichi Handa <handa@m17n.org>
28 538
29 * xdisp.c (compute_stop_pos): Call composition_compute_stop_pos 539 * xdisp.c (compute_stop_pos): Call composition_compute_stop_pos
@@ -18809,7 +19319,7 @@
18809 (Ffont_shape_text): New function. 19319 (Ffont_shape_text): New function.
18810 (Fopen_font): If the font size is not given, use 12-pixel. 19320 (Fopen_font): If the font size is not given, use 12-pixel.
18811 (Ffont_at): New arg STRING. 19321 (Ffont_at): New arg STRING.
18812 (syms_of_font): Initalize font_charset_alist. 19322 (syms_of_font): Initialize font_charset_alist.
18813 Declare Ffont_shape_text as a Lisp function. Call syms_of_XXfont 19323 Declare Ffont_shape_text as a Lisp function. Call syms_of_XXfont
18814 conditionally. 19324 conditionally.
18815 19325
@@ -19806,7 +20316,7 @@
19806 20316
19807 * font.c (font_unparse_fcname): Fix typo (swidth->width). 20317 * font.c (font_unparse_fcname): Fix typo (swidth->width).
19808 (font_list_entities): Check driver_list->on. 20318 (font_list_entities): Check driver_list->on.
19809 (register_font_driver): Initalize `on' member to 0. 20319 (register_font_driver): Initialize `on' member to 0.
19810 (font_update_drivers): New function. 20320 (font_update_drivers): New function.
19811 (Fclear_font_cache): Check driver_list->on. 20321 (Fclear_font_cache): Check driver_list->on.
19812 20322
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/Makefile.in b/src/Makefile.in
index 7fe3fe0ae81..00706460d25 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -286,6 +286,9 @@ LIBRESOLV = @LIBRESOLV@
286 286
287LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ 287LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
288 288
289LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
290LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
291
289INTERVALS_H = dispextern.h intervals.h composite.h 292INTERVALS_H = dispextern.h intervals.h composite.h
290 293
291GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ 294GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
@@ -325,6 +328,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} \
325 ${LIBXML2_CFLAGS} ${DBUS_CFLAGS} \ 328 ${LIBXML2_CFLAGS} ${DBUS_CFLAGS} \
326 ${GCONF_CFLAGS} ${FREETYPE_CFLAGS} ${FONTCONFIG_CFLAGS} \ 329 ${GCONF_CFLAGS} ${FREETYPE_CFLAGS} ${FONTCONFIG_CFLAGS} \
327 ${LIBOTF_CFLAGS} ${M17N_FLT_CFLAGS} ${DEPFLAGS} ${PROFILING_CFLAGS} \ 330 ${LIBOTF_CFLAGS} ${M17N_FLT_CFLAGS} ${DEPFLAGS} ${PROFILING_CFLAGS} \
331 $(LIBGNUTLS_CFLAGS) \
328 ${C_WARNINGS_SWITCH} ${CFLAGS} 332 ${C_WARNINGS_SWITCH} ${CFLAGS}
329ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) 333ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
330 334
@@ -349,7 +353,7 @@ obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
349 alloc.o data.o doc.o editfns.o callint.o \ 353 alloc.o data.o doc.o editfns.o callint.o \
350 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 \
351 syntax.o $(UNEXEC_OBJ) bytecode.o \ 355 syntax.o $(UNEXEC_OBJ) bytecode.o \
352 process.o callproc.o \ 356 process.o gnutls.o callproc.o \
353 region-cache.o sound.o atimer.o \ 357 region-cache.o sound.o atimer.o \
354 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 \
355 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) 359 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ)
@@ -601,6 +605,7 @@ LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
601 ${LIBXML2_LIBS} $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 605 ${LIBXML2_LIBS} $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
602 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \ 606 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \
603 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 607 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
608 $(LIBGNUTLS_LIBS) \
604 $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) 609 $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
605 610
606all: emacs${EXEEXT} $(OTHER_FILES) 611all: emacs${EXEEXT} $(OTHER_FILES)
diff --git a/src/alloc.c b/src/alloc.c
index 1f615a7d505..5cbc7cfe411 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1644,7 +1644,7 @@ static int total_strings, total_free_strings;
1644 1644
1645/* Number of bytes used by live strings. */ 1645/* Number of bytes used by live strings. */
1646 1646
1647static int total_string_size; 1647static EMACS_INT total_string_size;
1648 1648
1649/* Given a pointer to a Lisp_String S which is on the free-list 1649/* Given a pointer to a Lisp_String S which is on the free-list
1650 string_free_list, return a pointer to its successor in the 1650 string_free_list, return a pointer to its successor in the
@@ -1739,11 +1739,12 @@ static void check_sblock (struct sblock *);
1739 1739
1740/* Like GC_STRING_BYTES, but with debugging check. */ 1740/* Like GC_STRING_BYTES, but with debugging check. */
1741 1741
1742int 1742EMACS_INT
1743string_bytes (s) 1743string_bytes (struct Lisp_String *s)
1744 struct Lisp_String *s;
1745{ 1744{
1746 int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); 1745 EMACS_INT nbytes =
1746 (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte);
1747
1747 if (!PURE_POINTER_P (s) 1748 if (!PURE_POINTER_P (s)
1748 && s->data 1749 && s->data
1749 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) 1750 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
@@ -1765,7 +1766,7 @@ check_sblock (b)
1765 { 1766 {
1766 /* Compute the next FROM here because copying below may 1767 /* Compute the next FROM here because copying below may
1767 overwrite data we need to compute it. */ 1768 overwrite data we need to compute it. */
1768 int nbytes; 1769 EMACS_INT nbytes;
1769 1770
1770 /* Check that the string size recorded in the string is the 1771 /* Check that the string size recorded in the string is the
1771 same as the one recorded in the sdata structure. */ 1772 same as the one recorded in the sdata structure. */
@@ -1825,7 +1826,7 @@ check_string_free_list ()
1825 s = string_free_list; 1826 s = string_free_list;
1826 while (s != NULL) 1827 while (s != NULL)
1827 { 1828 {
1828 if ((unsigned)s < 1024) 1829 if ((unsigned long)s < 1024)
1829 abort(); 1830 abort();
1830 s = NEXT_FREE_LISP_STRING (s); 1831 s = NEXT_FREE_LISP_STRING (s);
1831 } 1832 }
@@ -1908,11 +1909,12 @@ allocate_string (void)
1908 S->data if it was initially non-null. */ 1909 S->data if it was initially non-null. */
1909 1910
1910void 1911void
1911allocate_string_data (struct Lisp_String *s, int nchars, int nbytes) 1912allocate_string_data (struct Lisp_String *s,
1913 EMACS_INT nchars, EMACS_INT nbytes)
1912{ 1914{
1913 struct sdata *data, *old_data; 1915 struct sdata *data, *old_data;
1914 struct sblock *b; 1916 struct sblock *b;
1915 int needed, old_nbytes; 1917 EMACS_INT needed, old_nbytes;
1916 1918
1917 /* Determine the number of bytes needed to store NBYTES bytes 1919 /* Determine the number of bytes needed to store NBYTES bytes
1918 of string data. */ 1920 of string data. */
@@ -2154,7 +2156,7 @@ compact_small_strings (void)
2154 { 2156 {
2155 /* Compute the next FROM here because copying below may 2157 /* Compute the next FROM here because copying below may
2156 overwrite data we need to compute it. */ 2158 overwrite data we need to compute it. */
2157 int nbytes; 2159 EMACS_INT nbytes;
2158 2160
2159#ifdef GC_CHECK_STRING_BYTES 2161#ifdef GC_CHECK_STRING_BYTES
2160 /* Check that the string size recorded in the string is the 2162 /* Check that the string size recorded in the string is the
@@ -2232,7 +2234,8 @@ INIT must be an integer that represents a character. */)
2232{ 2234{
2233 register Lisp_Object val; 2235 register Lisp_Object val;
2234 register unsigned char *p, *end; 2236 register unsigned char *p, *end;
2235 int c, nbytes; 2237 int c;
2238 EMACS_INT nbytes;
2236 2239
2237 CHECK_NATNUM (length); 2240 CHECK_NATNUM (length);
2238 CHECK_NUMBER (init); 2241 CHECK_NUMBER (init);
@@ -2251,9 +2254,12 @@ INIT must be an integer that represents a character. */)
2251 { 2254 {
2252 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2255 unsigned char str[MAX_MULTIBYTE_LENGTH];
2253 int len = CHAR_STRING (c, str); 2256 int len = CHAR_STRING (c, str);
2257 EMACS_INT string_len = XINT (length);
2254 2258
2255 nbytes = len * XINT (length); 2259 if (string_len > MOST_POSITIVE_FIXNUM / len)
2256 val = make_uninit_multibyte_string (XINT (length), nbytes); 2260 error ("Maximum string size exceeded");
2261 nbytes = len * string_len;
2262 val = make_uninit_multibyte_string (string_len, nbytes);
2257 p = SDATA (val); 2263 p = SDATA (val);
2258 end = p + nbytes; 2264 end = p + nbytes;
2259 while (p != end) 2265 while (p != end)
@@ -2276,7 +2282,8 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
2276 register Lisp_Object val; 2282 register Lisp_Object val;
2277 struct Lisp_Bool_Vector *p; 2283 struct Lisp_Bool_Vector *p;
2278 int real_init, i; 2284 int real_init, i;
2279 int length_in_chars, length_in_elts, bits_per_value; 2285 EMACS_INT length_in_chars, length_in_elts;
2286 int bits_per_value;
2280 2287
2281 CHECK_NATNUM (length); 2288 CHECK_NATNUM (length);
2282 2289
@@ -2316,10 +2323,10 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
2316 multibyte, depending on the contents. */ 2323 multibyte, depending on the contents. */
2317 2324
2318Lisp_Object 2325Lisp_Object
2319make_string (const char *contents, int nbytes) 2326make_string (const char *contents, EMACS_INT nbytes)
2320{ 2327{
2321 register Lisp_Object val; 2328 register Lisp_Object val;
2322 int nchars, multibyte_nbytes; 2329 EMACS_INT nchars, multibyte_nbytes;
2323 2330
2324 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); 2331 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes);
2325 if (nbytes == nchars || nbytes != multibyte_nbytes) 2332 if (nbytes == nchars || nbytes != multibyte_nbytes)
@@ -2335,7 +2342,7 @@ make_string (const char *contents, int nbytes)
2335/* Make an unibyte string from LENGTH bytes at CONTENTS. */ 2342/* Make an unibyte string from LENGTH bytes at CONTENTS. */
2336 2343
2337Lisp_Object 2344Lisp_Object
2338make_unibyte_string (const char *contents, int length) 2345make_unibyte_string (const char *contents, EMACS_INT length)
2339{ 2346{
2340 register Lisp_Object val; 2347 register Lisp_Object val;
2341 val = make_uninit_string (length); 2348 val = make_uninit_string (length);
@@ -2349,7 +2356,8 @@ make_unibyte_string (const char *contents, int length)
2349 bytes at CONTENTS. */ 2356 bytes at CONTENTS. */
2350 2357
2351Lisp_Object 2358Lisp_Object
2352make_multibyte_string (const char *contents, int nchars, int nbytes) 2359make_multibyte_string (const char *contents,
2360 EMACS_INT nchars, EMACS_INT nbytes)
2353{ 2361{
2354 register Lisp_Object val; 2362 register Lisp_Object val;
2355 val = make_uninit_multibyte_string (nchars, nbytes); 2363 val = make_uninit_multibyte_string (nchars, nbytes);
@@ -2362,7 +2370,8 @@ make_multibyte_string (const char *contents, int nchars, int nbytes)
2362 CONTENTS. It is a multibyte string if NBYTES != NCHARS. */ 2370 CONTENTS. It is a multibyte string if NBYTES != NCHARS. */
2363 2371
2364Lisp_Object 2372Lisp_Object
2365make_string_from_bytes (const char *contents, int nchars, int nbytes) 2373make_string_from_bytes (const char *contents,
2374 EMACS_INT nchars, EMACS_INT nbytes)
2366{ 2375{
2367 register Lisp_Object val; 2376 register Lisp_Object val;
2368 val = make_uninit_multibyte_string (nchars, nbytes); 2377 val = make_uninit_multibyte_string (nchars, nbytes);
@@ -2379,7 +2388,8 @@ make_string_from_bytes (const char *contents, int nchars, int nbytes)
2379 characters by itself. */ 2388 characters by itself. */
2380 2389
2381Lisp_Object 2390Lisp_Object
2382make_specified_string (const char *contents, int nchars, int nbytes, int multibyte) 2391make_specified_string (const char *contents,
2392 EMACS_INT nchars, EMACS_INT nbytes, int multibyte)
2383{ 2393{
2384 register Lisp_Object val; 2394 register Lisp_Object val;
2385 2395
@@ -2412,7 +2422,7 @@ build_string (const char *str)
2412 occupying LENGTH bytes. */ 2422 occupying LENGTH bytes. */
2413 2423
2414Lisp_Object 2424Lisp_Object
2415make_uninit_string (int length) 2425make_uninit_string (EMACS_INT length)
2416{ 2426{
2417 Lisp_Object val; 2427 Lisp_Object val;
2418 2428
@@ -2428,7 +2438,7 @@ make_uninit_string (int length)
2428 which occupy NBYTES bytes. */ 2438 which occupy NBYTES bytes. */
2429 2439
2430Lisp_Object 2440Lisp_Object
2431make_uninit_multibyte_string (int nchars, int nbytes) 2441make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
2432{ 2442{
2433 Lisp_Object string; 2443 Lisp_Object string;
2434 struct Lisp_String *s; 2444 struct Lisp_String *s;
@@ -2767,7 +2777,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
2767 (register Lisp_Object length, Lisp_Object init) 2777 (register Lisp_Object length, Lisp_Object init)
2768{ 2778{
2769 register Lisp_Object val; 2779 register Lisp_Object val;
2770 register int size; 2780 register EMACS_INT size;
2771 2781
2772 CHECK_NATNUM (length); 2782 CHECK_NATNUM (length);
2773 size = XFASTINT (length); 2783 size = XFASTINT (length);
@@ -2945,7 +2955,7 @@ See also the function `vector'. */)
2945{ 2955{
2946 Lisp_Object vector; 2956 Lisp_Object vector;
2947 register EMACS_INT sizei; 2957 register EMACS_INT sizei;
2948 register int index; 2958 register EMACS_INT index;
2949 register struct Lisp_Vector *p; 2959 register struct Lisp_Vector *p;
2950 2960
2951 CHECK_NATNUM (length); 2961 CHECK_NATNUM (length);
@@ -3785,7 +3795,7 @@ live_string_p (struct mem_node *m, void *p)
3785 if (m->type == MEM_TYPE_STRING) 3795 if (m->type == MEM_TYPE_STRING)
3786 { 3796 {
3787 struct string_block *b = (struct string_block *) m->start; 3797 struct string_block *b = (struct string_block *) m->start;
3788 int offset = (char *) p - (char *) &b->strings[0]; 3798 ptrdiff_t offset = (char *) p - (char *) &b->strings[0];
3789 3799
3790 /* P must point to the start of a Lisp_String structure, and it 3800 /* P must point to the start of a Lisp_String structure, and it
3791 must not be on the free-list. */ 3801 must not be on the free-list. */
@@ -3808,7 +3818,7 @@ live_cons_p (struct mem_node *m, void *p)
3808 if (m->type == MEM_TYPE_CONS) 3818 if (m->type == MEM_TYPE_CONS)
3809 { 3819 {
3810 struct cons_block *b = (struct cons_block *) m->start; 3820 struct cons_block *b = (struct cons_block *) m->start;
3811 int offset = (char *) p - (char *) &b->conses[0]; 3821 ptrdiff_t offset = (char *) p - (char *) &b->conses[0];
3812 3822
3813 /* P must point to the start of a Lisp_Cons, not be 3823 /* P must point to the start of a Lisp_Cons, not be
3814 one of the unused cells in the current cons block, 3824 one of the unused cells in the current cons block,
@@ -3834,7 +3844,7 @@ live_symbol_p (struct mem_node *m, void *p)
3834 if (m->type == MEM_TYPE_SYMBOL) 3844 if (m->type == MEM_TYPE_SYMBOL)
3835 { 3845 {
3836 struct symbol_block *b = (struct symbol_block *) m->start; 3846 struct symbol_block *b = (struct symbol_block *) m->start;
3837 int offset = (char *) p - (char *) &b->symbols[0]; 3847 ptrdiff_t offset = (char *) p - (char *) &b->symbols[0];
3838 3848
3839 /* P must point to the start of a Lisp_Symbol, not be 3849 /* P must point to the start of a Lisp_Symbol, not be
3840 one of the unused cells in the current symbol block, 3850 one of the unused cells in the current symbol block,
@@ -3860,7 +3870,7 @@ live_float_p (struct mem_node *m, void *p)
3860 if (m->type == MEM_TYPE_FLOAT) 3870 if (m->type == MEM_TYPE_FLOAT)
3861 { 3871 {
3862 struct float_block *b = (struct float_block *) m->start; 3872 struct float_block *b = (struct float_block *) m->start;
3863 int offset = (char *) p - (char *) &b->floats[0]; 3873 ptrdiff_t offset = (char *) p - (char *) &b->floats[0];
3864 3874
3865 /* P must point to the start of a Lisp_Float and not be 3875 /* P must point to the start of a Lisp_Float and not be
3866 one of the unused cells in the current float block. */ 3876 one of the unused cells in the current float block. */
@@ -3884,7 +3894,7 @@ live_misc_p (struct mem_node *m, void *p)
3884 if (m->type == MEM_TYPE_MISC) 3894 if (m->type == MEM_TYPE_MISC)
3885 { 3895 {
3886 struct marker_block *b = (struct marker_block *) m->start; 3896 struct marker_block *b = (struct marker_block *) m->start;
3887 int offset = (char *) p - (char *) &b->markers[0]; 3897 ptrdiff_t offset = (char *) p - (char *) &b->markers[0];
3888 3898
3889 /* P must point to the start of a Lisp_Misc, not be 3899 /* P must point to the start of a Lisp_Misc, not be
3890 one of the unused cells in the current misc block, 3900 one of the unused cells in the current misc block,
@@ -4591,9 +4601,10 @@ check_pure_size (void)
4591 address. Return NULL if not found. */ 4601 address. Return NULL if not found. */
4592 4602
4593static char * 4603static char *
4594find_string_data_in_pure (const char *data, int nbytes) 4604find_string_data_in_pure (const char *data, EMACS_INT nbytes)
4595{ 4605{
4596 int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max; 4606 int i;
4607 EMACS_INT skip, bm_skip[256], last_char_skip, infinity, start, start_max;
4597 const unsigned char *p; 4608 const unsigned char *p;
4598 char *non_lisp_beg; 4609 char *non_lisp_beg;
4599 4610
@@ -4660,7 +4671,8 @@ find_string_data_in_pure (const char *data, int nbytes)
4660 string; then the string is not protected from gc. */ 4671 string; then the string is not protected from gc. */
4661 4672
4662Lisp_Object 4673Lisp_Object
4663make_pure_string (const char *data, int nchars, int nbytes, int multibyte) 4674make_pure_string (const char *data,
4675 EMACS_INT nchars, EMACS_INT nbytes, int multibyte)
4664{ 4676{
4665 Lisp_Object string; 4677 Lisp_Object string;
4666 struct Lisp_String *s; 4678 struct Lisp_String *s;
@@ -4688,7 +4700,7 @@ make_pure_c_string (const char *data)
4688{ 4700{
4689 Lisp_Object string; 4701 Lisp_Object string;
4690 struct Lisp_String *s; 4702 struct Lisp_String *s;
4691 int nchars = strlen (data); 4703 EMACS_INT nchars = strlen (data);
4692 4704
4693 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); 4705 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
4694 s->size = nchars; 4706 s->size = nchars;
@@ -4778,7 +4790,7 @@ Does not copy symbols. Copies strings without text properties. */)
4778 else if (COMPILEDP (obj) || VECTORP (obj)) 4790 else if (COMPILEDP (obj) || VECTORP (obj))
4779 { 4791 {
4780 register struct Lisp_Vector *vec; 4792 register struct Lisp_Vector *vec;
4781 register int i; 4793 register EMACS_INT i;
4782 EMACS_INT size; 4794 EMACS_INT size;
4783 4795
4784 size = XVECTOR (obj)->size; 4796 size = XVECTOR (obj)->size;
@@ -5227,8 +5239,8 @@ static int mark_object_loop_halt;
5227static void 5239static void
5228mark_vectorlike (struct Lisp_Vector *ptr) 5240mark_vectorlike (struct Lisp_Vector *ptr)
5229{ 5241{
5230 register EMACS_INT size = ptr->size; 5242 register EMACS_UINT size = ptr->size;
5231 register int i; 5243 register EMACS_UINT i;
5232 5244
5233 eassert (!VECTOR_MARKED_P (ptr)); 5245 eassert (!VECTOR_MARKED_P (ptr));
5234 VECTOR_MARK (ptr); /* Else mark it */ 5246 VECTOR_MARK (ptr); /* Else mark it */
@@ -5250,8 +5262,8 @@ mark_vectorlike (struct Lisp_Vector *ptr)
5250static void 5262static void
5251mark_char_table (struct Lisp_Vector *ptr) 5263mark_char_table (struct Lisp_Vector *ptr)
5252{ 5264{
5253 register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; 5265 register EMACS_UINT size = ptr->size & PSEUDOVECTOR_SIZE_MASK;
5254 register int i; 5266 register EMACS_UINT i;
5255 5267
5256 eassert (!VECTOR_MARKED_P (ptr)); 5268 eassert (!VECTOR_MARKED_P (ptr));
5257 VECTOR_MARK (ptr); 5269 VECTOR_MARK (ptr);
@@ -5380,8 +5392,8 @@ mark_object (Lisp_Object arg)
5380 recursion there. */ 5392 recursion there. */
5381 { 5393 {
5382 register struct Lisp_Vector *ptr = XVECTOR (obj); 5394 register struct Lisp_Vector *ptr = XVECTOR (obj);
5383 register EMACS_INT size = ptr->size; 5395 register EMACS_UINT size = ptr->size;
5384 register int i; 5396 register EMACS_UINT i;
5385 5397
5386 CHECK_LIVE (live_vector_p); 5398 CHECK_LIVE (live_vector_p);
5387 VECTOR_MARK (ptr); /* Else mark it */ 5399 VECTOR_MARK (ptr); /* Else mark it */
diff --git a/src/bidi.c b/src/bidi.c
index 224ed552a6d..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
diff --git a/src/buffer.c b/src/buffer.c
index 84b60779b34..3f087d62a5f 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
@@ -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/cmds.c b/src/cmds.c
index 0e305e1fce4..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
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 630d341a20e..c28dc9b4bae 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2082,13 +2082,14 @@ ARRAY may be a vector, a string, a char-table, a bool-vector,
2082or a byte-code object. IDX starts at 0. */) 2082or a byte-code object. IDX starts at 0. */)
2083 (register Lisp_Object array, Lisp_Object idx) 2083 (register Lisp_Object array, Lisp_Object idx)
2084{ 2084{
2085 register int idxval; 2085 register EMACS_INT idxval;
2086 2086
2087 CHECK_NUMBER (idx); 2087 CHECK_NUMBER (idx);
2088 idxval = XINT (idx); 2088 idxval = XINT (idx);
2089 if (STRINGP (array)) 2089 if (STRINGP (array))
2090 { 2090 {
2091 int c, idxval_byte; 2091 int c;
2092 EMACS_INT idxval_byte;
2092 2093
2093 if (idxval < 0 || idxval >= SCHARS (array)) 2094 if (idxval < 0 || idxval >= SCHARS (array))
2094 args_out_of_range (array, idx); 2095 args_out_of_range (array, idx);
@@ -2136,7 +2137,7 @@ Return NEWELT. ARRAY may be a vector, a string, a char-table or a
2136bool-vector. IDX starts at 0. */) 2137bool-vector. IDX starts at 0. */)
2137 (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt) 2138 (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt)
2138{ 2139{
2139 register int idxval; 2140 register EMACS_INT idxval;
2140 2141
2141 CHECK_NUMBER (idx); 2142 CHECK_NUMBER (idx);
2142 idxval = XINT (idx); 2143 idxval = XINT (idx);
@@ -2171,7 +2172,7 @@ bool-vector. IDX starts at 0. */)
2171 } 2172 }
2172 else if (STRING_MULTIBYTE (array)) 2173 else if (STRING_MULTIBYTE (array))
2173 { 2174 {
2174 int idxval_byte, prev_bytes, new_bytes, nbytes; 2175 EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes;
2175 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; 2176 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;
2176 2177
2177 if (idxval < 0 || idxval >= SCHARS (array)) 2178 if (idxval < 0 || idxval >= SCHARS (array))
@@ -2187,7 +2188,7 @@ bool-vector. IDX starts at 0. */)
2187 if (prev_bytes != new_bytes) 2188 if (prev_bytes != new_bytes)
2188 { 2189 {
2189 /* We must relocate the string data. */ 2190 /* We must relocate the string data. */
2190 int nchars = SCHARS (array); 2191 EMACS_INT nchars = SCHARS (array);
2191 unsigned char *str; 2192 unsigned char *str;
2192 USE_SAFE_ALLOCA; 2193 USE_SAFE_ALLOCA;
2193 2194
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 3b6f0e543bb..a8db1c510c7 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,93 @@ xd_initialize (Lisp_Object bus, int raise_error)
799 return connection; 800 return connection;
800} 801}
801 802
803/* Callback called when something is read to read ow write. */
802 804
803/* Add connection file descriptor to input_wait_mask, in order to 805static void
804 let select() detect, whether a new message has been arrived. */ 806dbus_fd_cb (int fd, void *data, int for_read)
805dbus_bool_t 807{
806xd_add_watch (DBusWatch *watch, void *data) 808 xd_read_queued_messages ();
809}
810
811/* Return the file descriptor for WATCH, -1 if not found. */
812
813static int
814xd_find_watch_fd (DBusWatch *watch)
807{ 815{
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 816#if HAVE_DBUS_WATCH_GET_UNIX_FD
812 /* TODO: Reverse these on Win32, which prefers the opposite. */ 817 /* TODO: Reverse these on Win32, which prefers the opposite. */
813 int fd = dbus_watch_get_unix_fd(watch); 818 int fd = dbus_watch_get_unix_fd (watch);
814 if (fd == -1) 819 if (fd == -1)
815 fd = dbus_watch_get_socket(watch); 820 fd = dbus_watch_get_socket (watch);
816#else 821#else
817 int fd = dbus_watch_get_fd(watch); 822 int fd = dbus_watch_get_fd (watch);
818#endif 823#endif
819 XD_DEBUG_MESSAGE ("fd %d", fd); 824 return fd;
825}
820 826
821 if (fd == -1)
822 return FALSE;
823 827
824 /* Add the file descriptor to input_wait_mask. */ 828/* Start monitoring WATCH for possible I/O. */
825 add_keyboard_wait_descriptor (fd);
826 }
827 829
828 /* Return. */ 830static dbus_bool_t
831xd_add_watch (DBusWatch *watch, void *data)
832{
833 unsigned int flags = dbus_watch_get_flags (watch);
834 int fd = xd_find_watch_fd (watch);
835
836 XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d",
837 fd, flags & DBUS_WATCH_WRITABLE,
838 dbus_watch_get_enabled (watch));
839
840 if (fd == -1)
841 return FALSE;
842
843 if (dbus_watch_get_enabled (watch))
844 {
845 if (flags & DBUS_WATCH_WRITABLE)
846 add_write_fd (fd, dbus_fd_cb, NULL);
847 if (flags & DBUS_WATCH_READABLE)
848 add_read_fd (fd, dbus_fd_cb, NULL);
849 }
829 return TRUE; 850 return TRUE;
830} 851}
831 852
832/* Remove connection file descriptor from input_wait_mask. DATA is 853/* Stop monitoring WATCH for possible I/O.
833 the used bus, either a string or QCdbus_system_bus or 854 DATA is the used bus, either a string or QCdbus_system_bus or
834 QCdbus_session_bus. */ 855 QCdbus_session_bus. */
835void 856
857static void
836xd_remove_watch (DBusWatch *watch, void *data) 858xd_remove_watch (DBusWatch *watch, void *data)
837{ 859{
838 /* We check only for incoming data. */ 860 unsigned int flags = dbus_watch_get_flags (watch);
839 if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) 861 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 862
851 if (fd == -1) 863 XD_DEBUG_MESSAGE ("fd %d", fd);
852 return; 864
865 if (fd == -1) return;
853 866
854 /* Unset session environment. */
855 if ((data != NULL) && (data == (void*) XHASH (QCdbus_session_bus)))
856 {
857 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
858 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
859 }
860 867
861 /* Remove the file descriptor from input_wait_mask. */ 868 /* Unset session environment. */
862 delete_keyboard_wait_descriptor (fd); 869 if (data != NULL && data == (void*) XHASH (QCdbus_session_bus))
870 {
871 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
872 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
863 } 873 }
864 874
865 /* Return. */ 875 if (flags & DBUS_WATCH_WRITABLE)
866 return; 876 delete_write_fd (fd);
877 if (flags & DBUS_WATCH_READABLE)
878 delete_read_fd (fd);
879}
880
881/* Toggle monitoring WATCH for possible I/O. */
882
883static void
884xd_toggle_watch (DBusWatch *watch, void *data)
885{
886 if (dbus_watch_get_enabled (watch))
887 xd_add_watch (watch, data);
888 else
889 xd_remove_watch (watch, data);
867} 890}
868 891
869DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, 892DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
@@ -880,7 +903,8 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
880 if (!dbus_connection_set_watch_functions (connection, 903 if (!dbus_connection_set_watch_functions (connection,
881 xd_add_watch, 904 xd_add_watch,
882 xd_remove_watch, 905 xd_remove_watch,
883 NULL, (void*) XHASH (bus), NULL)) 906 xd_toggle_watch,
907 (void*) XHASH (bus), NULL))
884 XD_SIGNAL1 (build_string ("Cannot add watch functions")); 908 XD_SIGNAL1 (build_string ("Cannot add watch functions"));
885 909
886 /* Add bus to list of registered buses. */ 910 /* Add bus to list of registered buses. */
@@ -1288,9 +1312,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE
1288 result = Qnil; 1312 result = Qnil;
1289 } 1313 }
1290 1314
1291 /* Flush connection to ensure the message is handled. */
1292 dbus_connection_flush (connection);
1293
1294 XD_DEBUG_MESSAGE ("Message sent"); 1315 XD_DEBUG_MESSAGE ("Message sent");
1295 1316
1296 /* Cleanup. */ 1317 /* Cleanup. */
@@ -1379,9 +1400,6 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */)
1379 if (!dbus_connection_send (connection, dmessage, NULL)) 1400 if (!dbus_connection_send (connection, dmessage, NULL))
1380 XD_SIGNAL1 (build_string ("Cannot send message")); 1401 XD_SIGNAL1 (build_string ("Cannot send message"));
1381 1402
1382 /* Flush connection to ensure the message is handled. */
1383 dbus_connection_flush (connection);
1384
1385 XD_DEBUG_MESSAGE ("Message sent"); 1403 XD_DEBUG_MESSAGE ("Message sent");
1386 1404
1387 /* Cleanup. */ 1405 /* Cleanup. */
@@ -1471,9 +1489,6 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */)
1471 if (!dbus_connection_send (connection, dmessage, NULL)) 1489 if (!dbus_connection_send (connection, dmessage, NULL))
1472 XD_SIGNAL1 (build_string ("Cannot send message")); 1490 XD_SIGNAL1 (build_string ("Cannot send message"));
1473 1491
1474 /* Flush connection to ensure the message is handled. */
1475 dbus_connection_flush (connection);
1476
1477 XD_DEBUG_MESSAGE ("Message sent"); 1492 XD_DEBUG_MESSAGE ("Message sent");
1478 1493
1479 /* Cleanup. */ 1494 /* Cleanup. */
@@ -1589,9 +1604,6 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
1589 if (!dbus_connection_send (connection, dmessage, NULL)) 1604 if (!dbus_connection_send (connection, dmessage, NULL))
1590 XD_SIGNAL1 (build_string ("Cannot send message")); 1605 XD_SIGNAL1 (build_string ("Cannot send message"));
1591 1606
1592 /* Flush connection to ensure the message is handled. */
1593 dbus_connection_flush (connection);
1594
1595 XD_DEBUG_MESSAGE ("Signal sent"); 1607 XD_DEBUG_MESSAGE ("Signal sent");
1596 1608
1597 /* Cleanup. */ 1609 /* Cleanup. */
@@ -1645,32 +1657,27 @@ xd_pending_messages (void)
1645 return FALSE; 1657 return FALSE;
1646} 1658}
1647 1659
1648/* Read queued incoming message of the D-Bus BUS. BUS is either a 1660/* Read one queued incoming message of the D-Bus BUS.
1649 Lisp symbol, :system or :session, or a string denoting the bus 1661 BUS is either a Lisp symbol, :system or :session, or a string denoting
1650 address. */ 1662 the bus address. */
1651static Lisp_Object 1663
1652xd_read_message (Lisp_Object bus) 1664static void
1665xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
1653{ 1666{
1654 Lisp_Object args, key, value; 1667 Lisp_Object args, key, value;
1655 struct gcpro gcpro1; 1668 struct gcpro gcpro1;
1656 struct input_event event; 1669 struct input_event event;
1657 DBusConnection *connection;
1658 DBusMessage *dmessage; 1670 DBusMessage *dmessage;
1659 DBusMessageIter iter; 1671 DBusMessageIter iter;
1660 unsigned int dtype; 1672 unsigned int dtype;
1661 int mtype, serial; 1673 int mtype, serial;
1662 const char *uname, *path, *interface, *member; 1674 const char *uname, *path, *interface, *member;
1663 1675
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); 1676 dmessage = dbus_connection_pop_message (connection);
1670 1677
1671 /* Return if there is no queued message. */ 1678 /* Return if there is no queued message. */
1672 if (dmessage == NULL) 1679 if (dmessage == NULL)
1673 return Qnil; 1680 return;
1674 1681
1675 /* Collect the parameters. */ 1682 /* Collect the parameters. */
1676 args = Qnil; 1683 args = Qnil;
@@ -1801,7 +1808,26 @@ xd_read_message (Lisp_Object bus)
1801 cleanup: 1808 cleanup:
1802 dbus_message_unref (dmessage); 1809 dbus_message_unref (dmessage);
1803 1810
1804 RETURN_UNGCPRO (Qnil); 1811 UNGCPRO;
1812}
1813
1814/* Read queued incoming messages of the D-Bus BUS.
1815 BUS is either a Lisp symbol, :system or :session, or a string denoting
1816 the bus address. */
1817
1818static Lisp_Object
1819xd_read_message (Lisp_Object bus)
1820{
1821 /* Open a connection to the bus. */
1822 DBusConnection *connection = xd_initialize (bus, TRUE);
1823
1824 /* Non blocking read of the next available message. */
1825 dbus_connection_read_write (connection, 0);
1826
1827 while (dbus_connection_get_dispatch_status (connection)
1828 != DBUS_DISPATCH_COMPLETE)
1829 xd_read_message_1 (connection, bus);
1830 return Qnil;
1805} 1831}
1806 1832
1807/* Read queued incoming messages from all buses. */ 1833/* Read queued incoming messages from all buses. */
diff --git a/src/dispextern.h b/src/dispextern.h
index 95c574ea339..71276fbe950 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1783,7 +1783,7 @@ typedef enum { NEUTRAL_DIR, L2R, R2L } bidi_dir_t;
1783/* Data type for storing information about characters we need to 1783/* Data type for storing information about characters we need to
1784 remember. */ 1784 remember. */
1785struct bidi_saved_info { 1785struct bidi_saved_info {
1786 int bytepos, charpos; /* character's buffer position */ 1786 EMACS_INT bytepos, charpos; /* character's buffer position */
1787 bidi_type_t type; /* character's resolved bidi type */ 1787 bidi_type_t type; /* character's resolved bidi type */
1788 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 */
1789 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 */
@@ -2942,7 +2942,8 @@ void remember_mouse_glyph (struct frame *, int, int, NativeRectangle *);
2942void mark_window_display_accurate (Lisp_Object, int); 2942void mark_window_display_accurate (Lisp_Object, int);
2943void redisplay_preserve_echo_area (int); 2943void redisplay_preserve_echo_area (int);
2944int set_cursor_from_row (struct window *, struct glyph_row *, 2944int set_cursor_from_row (struct window *, struct glyph_row *,
2945 struct glyph_matrix *, int, int, int, int); 2945 struct glyph_matrix *, EMACS_INT, EMACS_INT,
2946 int, int);
2946void init_iterator (struct it *, struct window *, EMACS_INT, 2947void init_iterator (struct it *, struct window *, EMACS_INT,
2947 EMACS_INT, struct glyph_row *, enum face_id); 2948 EMACS_INT, struct glyph_row *, enum face_id);
2948void init_iterator_to_row_start (struct it *, struct window *, 2949void init_iterator_to_row_start (struct it *, struct window *,
@@ -2950,7 +2951,7 @@ void init_iterator_to_row_start (struct it *, struct window *,
2950int get_next_display_element (struct it *); 2951int get_next_display_element (struct it *);
2951void set_iterator_to_next (struct it *, int); 2952void set_iterator_to_next (struct it *, int);
2952void start_display (struct it *, struct window *, struct text_pos); 2953void start_display (struct it *, struct window *, struct text_pos);
2953void move_it_to (struct it *, int, int, int, int, int); 2954void move_it_to (struct it *, EMACS_INT, int, int, int, int);
2954void move_it_vertically (struct it *, int); 2955void move_it_vertically (struct it *, int);
2955void move_it_vertically_backward (struct it *, int); 2956void move_it_vertically_backward (struct it *, int);
2956void move_it_by_lines (struct it *, int, int); 2957void move_it_by_lines (struct it *, int, int);
@@ -2969,7 +2970,7 @@ extern int help_echo_showing_p;
2969extern int current_mode_line_height, current_header_line_height; 2970extern int current_mode_line_height, current_header_line_height;
2970extern Lisp_Object help_echo_string, help_echo_window; 2971extern Lisp_Object help_echo_string, help_echo_window;
2971extern Lisp_Object help_echo_object, previous_help_echo_string; 2972extern Lisp_Object help_echo_object, previous_help_echo_string;
2972extern int help_echo_pos; 2973extern EMACS_INT help_echo_pos;
2973extern struct frame *last_mouse_frame; 2974extern struct frame *last_mouse_frame;
2974extern int last_tool_bar_item; 2975extern int last_tool_bar_item;
2975extern Lisp_Object Vmouse_autoselect_window; 2976extern Lisp_Object Vmouse_autoselect_window;
@@ -3222,11 +3223,11 @@ extern Lisp_Object buffer_posn_from_coords (struct window *,
3222 Lisp_Object *, 3223 Lisp_Object *,
3223 int *, int *, int *, int *); 3224 int *, int *, int *, int *);
3224extern Lisp_Object mode_line_string (struct window *, enum window_part, 3225extern Lisp_Object mode_line_string (struct window *, enum window_part,
3225 int *, int *, int *, 3226 int *, int *, EMACS_INT *,
3226 Lisp_Object *, 3227 Lisp_Object *,
3227 int *, int *, int *, int *); 3228 int *, int *, int *, int *);
3228extern Lisp_Object marginal_area_string (struct window *, enum window_part, 3229extern Lisp_Object marginal_area_string (struct window *, enum window_part,
3229 int *, int *, int *, 3230 int *, int *, EMACS_INT *,
3230 Lisp_Object *, 3231 Lisp_Object *,
3231 int *, int *, int *, int *); 3232 int *, int *, int *, int *);
3232extern void redraw_frame (struct frame *); 3233extern void redraw_frame (struct frame *);
@@ -3249,9 +3250,9 @@ void shift_glyph_matrix (struct window *, struct glyph_matrix *,
3249 int, int, int); 3250 int, int, int);
3250void rotate_matrix (struct glyph_matrix *, int, int, int); 3251void rotate_matrix (struct glyph_matrix *, int, int, int);
3251void increment_matrix_positions (struct glyph_matrix *, 3252void increment_matrix_positions (struct glyph_matrix *,
3252 int, int, int, int); 3253 int, int, EMACS_INT, EMACS_INT);
3253void blank_row (struct window *, struct glyph_row *, int); 3254void blank_row (struct window *, struct glyph_row *, int);
3254void increment_row_positions (struct glyph_row *, int, int); 3255void increment_row_positions (struct glyph_row *, EMACS_INT, EMACS_INT);
3255void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int); 3256void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int);
3256void clear_glyph_row (struct glyph_row *); 3257void clear_glyph_row (struct glyph_row *);
3257void prepare_desired_row (struct glyph_row *); 3258void prepare_desired_row (struct glyph_row *);
diff --git a/src/dispnew.c b/src/dispnew.c
index acd2778c97d..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
@@ -5498,7 +5501,9 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5498 *CHARPOS is set to the position in the string returned. */ 5501 *CHARPOS is set to the position in the string returned. */
5499 5502
5500Lisp_Object 5503Lisp_Object
5501mode_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)
5502{ 5507{
5503 struct glyph_row *row; 5508 struct glyph_row *row;
5504 struct glyph *glyph, *end; 5509 struct glyph *glyph, *end;
@@ -5565,7 +5570,9 @@ mode_line_string (struct window *w, enum window_part part, int *x, int *y, int *
5565 the string returned. */ 5570 the string returned. */
5566 5571
5567Lisp_Object 5572Lisp_Object
5568marginal_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)
5569{ 5576{
5570 struct glyph_row *row = w->current_matrix->rows; 5577 struct glyph_row *row = w->current_matrix->rows;
5571 struct glyph *glyph, *end; 5578 struct glyph *glyph, *end;
diff --git a/src/doc.c b/src/doc.c
index 36f7c0e882a..8d5727b95c6 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -99,8 +99,8 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
99 register int fd; 99 register int fd;
100 register char *name; 100 register char *name;
101 register char *p, *p1; 101 register char *p, *p1;
102 int minsize; 102 EMACS_INT minsize;
103 int offset, position; 103 EMACS_INT offset, position;
104 Lisp_Object file, tem; 104 Lisp_Object file, tem;
105 105
106 if (INTEGERP (filepos)) 106 if (INTEGERP (filepos))
@@ -179,14 +179,14 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
179 p = get_doc_string_buffer; 179 p = get_doc_string_buffer;
180 while (1) 180 while (1)
181 { 181 {
182 int space_left = (get_doc_string_buffer_size 182 EMACS_INT space_left = (get_doc_string_buffer_size
183 - (p - get_doc_string_buffer)); 183 - (p - get_doc_string_buffer));
184 int nread; 184 int nread;
185 185
186 /* Allocate or grow the buffer if we need to. */ 186 /* Allocate or grow the buffer if we need to. */
187 if (space_left == 0) 187 if (space_left == 0)
188 { 188 {
189 int in_buffer = p - get_doc_string_buffer; 189 EMACS_INT in_buffer = p - get_doc_string_buffer;
190 get_doc_string_buffer_size += 16 * 1024; 190 get_doc_string_buffer_size += 16 * 1024;
191 get_doc_string_buffer 191 get_doc_string_buffer
192 = (char *) xrealloc (get_doc_string_buffer, 192 = (char *) xrealloc (get_doc_string_buffer,
@@ -286,8 +286,8 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
286 else 286 else
287 { 287 {
288 /* The data determines whether the string is multibyte. */ 288 /* The data determines whether the string is multibyte. */
289 int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, 289 EMACS_INT nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
290 to - (get_doc_string_buffer + offset)); 290 to - (get_doc_string_buffer + offset));
291 return make_string_from_bytes (get_doc_string_buffer + offset, 291 return make_string_from_bytes (get_doc_string_buffer + offset,
292 nchars, 292 nchars,
293 to - (get_doc_string_buffer + offset)); 293 to - (get_doc_string_buffer + offset));
@@ -551,8 +551,8 @@ the same file name is found in the `doc-directory'. */)
551{ 551{
552 int fd; 552 int fd;
553 char buf[1024 + 1]; 553 char buf[1024 + 1];
554 register int filled; 554 register EMACS_INT filled;
555 register int pos; 555 register EMACS_INT pos;
556 register char *p, *end; 556 register char *p, *end;
557 Lisp_Object sym; 557 Lisp_Object sym;
558 char *name; 558 char *name;
@@ -586,7 +586,7 @@ the same file name is found in the `doc-directory'. */)
586 586
587 for (beg = buildobj; *beg; beg = end) 587 for (beg = buildobj; *beg; beg = end)
588 { 588 {
589 int len; 589 EMACS_INT len;
590 590
591 while (*beg && isspace (*beg)) ++beg; 591 while (*beg && isspace (*beg)) ++beg;
592 592
@@ -633,7 +633,7 @@ the same file name is found in the `doc-directory'. */)
633 if (end - p > 4 && end[-2] == '.' 633 if (end - p > 4 && end[-2] == '.'
634 && (end[-1] == 'o' || end[-1] == 'c')) 634 && (end[-1] == 'o' || end[-1] == 'c'))
635 { 635 {
636 int len = end - p - 2; 636 EMACS_INT len = end - p - 2;
637 char *fromfile = alloca (len + 1); 637 char *fromfile = alloca (len + 1);
638 strncpy (fromfile, &p[2], len); 638 strncpy (fromfile, &p[2], len);
639 fromfile[len] = 0; 639 fromfile[len] = 0;
@@ -705,16 +705,16 @@ a new string, without any text properties, is returned. */)
705 int changed = 0; 705 int changed = 0;
706 register unsigned char *strp; 706 register unsigned char *strp;
707 register unsigned char *bufp; 707 register unsigned char *bufp;
708 int idx; 708 EMACS_INT idx;
709 int bsize; 709 EMACS_INT bsize;
710 Lisp_Object tem; 710 Lisp_Object tem;
711 Lisp_Object keymap; 711 Lisp_Object keymap;
712 unsigned char *start; 712 unsigned char *start;
713 int length, length_byte; 713 EMACS_INT length, length_byte;
714 Lisp_Object name; 714 Lisp_Object name;
715 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 715 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
716 int multibyte; 716 int multibyte;
717 int nchars; 717 EMACS_INT nchars;
718 718
719 if (NILP (string)) 719 if (NILP (string))
720 return Qnil; 720 return Qnil;
@@ -766,7 +766,7 @@ a new string, without any text properties, is returned. */)
766 } 766 }
767 else if (strp[0] == '\\' && strp[1] == '[') 767 else if (strp[0] == '\\' && strp[1] == '[')
768 { 768 {
769 int start_idx; 769 EMACS_INT start_idx;
770 int follow_remap = 1; 770 int follow_remap = 1;
771 771
772 changed = 1; 772 changed = 1;
@@ -805,7 +805,7 @@ a new string, without any text properties, is returned. */)
805 805
806 if (NILP (tem)) /* but not on any keys */ 806 if (NILP (tem)) /* but not on any keys */
807 { 807 {
808 int offset = bufp - buf; 808 EMACS_INT offset = bufp - buf;
809 buf = (unsigned char *) xrealloc (buf, bsize += 4); 809 buf = (unsigned char *) xrealloc (buf, bsize += 4);
810 bufp = buf + offset; 810 bufp = buf + offset;
811 memcpy (bufp, "M-x ", 4); 811 memcpy (bufp, "M-x ", 4);
@@ -828,7 +828,7 @@ a new string, without any text properties, is returned. */)
828 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) 828 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
829 { 829 {
830 struct buffer *oldbuf; 830 struct buffer *oldbuf;
831 int start_idx; 831 EMACS_INT start_idx;
832 /* This is for computing the SHADOWS arg for describe_map_tree. */ 832 /* This is for computing the SHADOWS arg for describe_map_tree. */
833 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); 833 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
834 Lisp_Object earlier_maps; 834 Lisp_Object earlier_maps;
@@ -899,7 +899,7 @@ a new string, without any text properties, is returned. */)
899 length_byte = SBYTES (tem); 899 length_byte = SBYTES (tem);
900 subst: 900 subst:
901 { 901 {
902 int offset = bufp - buf; 902 EMACS_INT offset = bufp - buf;
903 buf = (unsigned char *) xrealloc (buf, bsize += length_byte); 903 buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
904 bufp = buf + offset; 904 bufp = buf + offset;
905 memcpy (bufp, start, length_byte); 905 memcpy (bufp, start, length_byte);
diff --git a/src/doprnt.c b/src/doprnt.c
index 053fa183e6b..02adc51f1e5 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -54,7 +54,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
54 String arguments are passed as C strings. 54 String arguments are passed as C strings.
55 Integers are passed as C integers. */ 55 Integers are passed as C integers. */
56 56
57int 57EMACS_INT
58doprnt (char *buffer, register int bufsize, const char *format, 58doprnt (char *buffer, register int bufsize, const char *format,
59 const char *format_end, va_list ap) 59 const char *format_end, va_list ap)
60{ 60{
@@ -96,7 +96,7 @@ doprnt (char *buffer, register int bufsize, const char *format,
96 if (*fmt == '%') /* Check for a '%' character */ 96 if (*fmt == '%') /* Check for a '%' character */
97 { 97 {
98 unsigned size_bound = 0; 98 unsigned size_bound = 0;
99 int width; /* Columns occupied by STRING. */ 99 EMACS_INT width; /* Columns occupied by STRING. */
100 100
101 fmt++; 101 fmt++;
102 /* Copy this one %-spec into fmtcpy. */ 102 /* Copy this one %-spec into fmtcpy. */
diff --git a/src/editfns.c b/src/editfns.c
index add2f37109b..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;
@@ -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 5e7efb64226..397b6d1ce88 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -59,6 +59,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
59#include "keyboard.h" 59#include "keyboard.h"
60#include "keymap.h" 60#include "keymap.h"
61 61
62#ifdef HAVE_GNUTLS
63#include "gnutls.h"
64#endif
65
62#ifdef HAVE_NS 66#ifdef HAVE_NS
63#include "nsterm.h" 67#include "nsterm.h"
64#endif 68#endif
@@ -1569,6 +1573,10 @@ main (int argc, char **argv)
1569 syms_of_fontset (); 1573 syms_of_fontset ();
1570#endif /* HAVE_NS */ 1574#endif /* HAVE_NS */
1571 1575
1576#ifdef HAVE_GNUTLS
1577 syms_of_gnutls ();
1578#endif
1579
1572#ifdef HAVE_DBUS 1580#ifdef HAVE_DBUS
1573 syms_of_dbusbind (); 1581 syms_of_dbusbind ();
1574#endif /* HAVE_DBUS */ 1582#endif /* HAVE_DBUS */
diff --git a/src/eval.c b/src/eval.c
index 89d353cf7cb..d64d15040df 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -79,7 +79,7 @@ Lisp_Object Vautoload_queue;
79 79
80/* Current number of specbindings allocated in specpdl. */ 80/* Current number of specbindings allocated in specpdl. */
81 81
82int specpdl_size; 82EMACS_INT specpdl_size;
83 83
84/* Pointer to beginning of specpdl. */ 84/* Pointer to beginning of specpdl. */
85 85
@@ -95,7 +95,7 @@ EMACS_INT max_specpdl_size;
95 95
96/* Depth in Lisp evaluations and function calls. */ 96/* Depth in Lisp evaluations and function calls. */
97 97
98int lisp_eval_depth; 98EMACS_INT lisp_eval_depth;
99 99
100/* Maximum allowed depth in Lisp evaluations and function calls. */ 100/* Maximum allowed depth in Lisp evaluations and function calls. */
101 101
@@ -216,7 +216,7 @@ call_debugger (Lisp_Object arg)
216 int debug_while_redisplaying; 216 int debug_while_redisplaying;
217 int count = SPECPDL_INDEX (); 217 int count = SPECPDL_INDEX ();
218 Lisp_Object val; 218 Lisp_Object val;
219 int old_max = max_specpdl_size; 219 EMACS_INT old_max = max_specpdl_size;
220 220
221 /* Temporarily bump up the stack limits, 221 /* Temporarily bump up the stack limits,
222 so the debugger won't run out of stack. */ 222 so the debugger won't run out of stack. */
@@ -1992,7 +1992,7 @@ void
1992verror (const char *m, va_list ap) 1992verror (const char *m, va_list ap)
1993{ 1993{
1994 char buf[200]; 1994 char buf[200];
1995 int size = 200; 1995 EMACS_INT size = 200;
1996 int mlen; 1996 int mlen;
1997 char *buffer = buf; 1997 char *buffer = buf;
1998 char *args[3]; 1998 char *args[3];
@@ -2003,7 +2003,7 @@ verror (const char *m, va_list ap)
2003 2003
2004 while (1) 2004 while (1)
2005 { 2005 {
2006 int used; 2006 EMACS_INT used;
2007 used = doprnt (buffer, size, m, m + mlen, ap); 2007 used = doprnt (buffer, size, m, m + mlen, ap);
2008 if (used < size) 2008 if (used < size)
2009 break; 2009 break;
diff --git a/src/fns.c b/src/fns.c
index 19590a2140d..19d534e7fda 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)) 527 if (VECTORP (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
@@ -2147,7 +2148,9 @@ DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0,
2147ARRAY is a vector, string, char-table, or bool-vector. */) 2148ARRAY is a vector, string, char-table, or bool-vector. */)
2148 (Lisp_Object array, Lisp_Object item) 2149 (Lisp_Object array, Lisp_Object item)
2149{ 2150{
2150 register int size, index, charval; 2151 register EMACS_INT size, index;
2152 int charval;
2153
2151 if (VECTORP (array)) 2154 if (VECTORP (array))
2152 { 2155 {
2153 register Lisp_Object *p = XVECTOR (array)->contents; 2156 register Lisp_Object *p = XVECTOR (array)->contents;
@@ -2173,7 +2176,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2173 { 2176 {
2174 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2177 unsigned char str[MAX_MULTIBYTE_LENGTH];
2175 int len = CHAR_STRING (charval, str); 2178 int len = CHAR_STRING (charval, str);
2176 int size_byte = SBYTES (array); 2179 EMACS_INT size_byte = SBYTES (array);
2177 unsigned char *p1 = p, *endp = p + size_byte; 2180 unsigned char *p1 = p, *endp = p + size_byte;
2178 int i; 2181 int i;
2179 2182
@@ -2221,7 +2224,7 @@ DEFUN ("clear-string", Fclear_string, Sclear_string,
2221This makes STRING unibyte and may change its length. */) 2224This makes STRING unibyte and may change its length. */)
2222 (Lisp_Object string) 2225 (Lisp_Object string)
2223{ 2226{
2224 int len; 2227 EMACS_INT len;
2225 CHECK_STRING (string); 2228 CHECK_STRING (string);
2226 len = SBYTES (string); 2229 len = SBYTES (string);
2227 memset (SDATA (string), 0, len); 2230 memset (SDATA (string), 0, len);
@@ -2285,11 +2288,11 @@ usage: (nconc &rest LISTS) */)
2285 LENI is the length of VALS, which should also be the length of SEQ. */ 2288 LENI is the length of VALS, which should also be the length of SEQ. */
2286 2289
2287static void 2290static void
2288mapcar1 (int leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq) 2291mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
2289{ 2292{
2290 register Lisp_Object tail; 2293 register Lisp_Object tail;
2291 Lisp_Object dummy; 2294 Lisp_Object dummy;
2292 register int i; 2295 register EMACS_INT i;
2293 struct gcpro gcpro1, gcpro2, gcpro3; 2296 struct gcpro gcpro1, gcpro2, gcpro3;
2294 2297
2295 if (vals) 2298 if (vals)
@@ -2331,12 +2334,12 @@ mapcar1 (int leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
2331 } 2334 }
2332 else if (STRINGP (seq)) 2335 else if (STRINGP (seq))
2333 { 2336 {
2334 int i_byte; 2337 EMACS_INT i_byte;
2335 2338
2336 for (i = 0, i_byte = 0; i < leni;) 2339 for (i = 0, i_byte = 0; i < leni;)
2337 { 2340 {
2338 int c; 2341 int c;
2339 int i_before = i; 2342 EMACS_INT i_before = i;
2340 2343
2341 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte); 2344 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte);
2342 XSETFASTINT (dummy, c); 2345 XSETFASTINT (dummy, c);
@@ -2368,10 +2371,10 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2368 (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator) 2371 (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator)
2369{ 2372{
2370 Lisp_Object len; 2373 Lisp_Object len;
2371 register int leni; 2374 register EMACS_INT leni;
2372 int nargs; 2375 int nargs;
2373 register Lisp_Object *args; 2376 register Lisp_Object *args;
2374 register int i; 2377 register EMACS_INT i;
2375 struct gcpro gcpro1; 2378 struct gcpro gcpro1;
2376 Lisp_Object ret; 2379 Lisp_Object ret;
2377 USE_SAFE_ALLOCA; 2380 USE_SAFE_ALLOCA;
@@ -2408,7 +2411,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2408 (Lisp_Object function, Lisp_Object sequence) 2411 (Lisp_Object function, Lisp_Object sequence)
2409{ 2412{
2410 register Lisp_Object len; 2413 register Lisp_Object len;
2411 register int leni; 2414 register EMACS_INT leni;
2412 register Lisp_Object *args; 2415 register Lisp_Object *args;
2413 Lisp_Object ret; 2416 Lisp_Object ret;
2414 USE_SAFE_ALLOCA; 2417 USE_SAFE_ALLOCA;
@@ -2434,7 +2437,7 @@ Unlike `mapcar', don't accumulate the results. Return SEQUENCE.
2434SEQUENCE may be a list, a vector, a bool-vector, or a string. */) 2437SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2435 (Lisp_Object function, Lisp_Object sequence) 2438 (Lisp_Object function, Lisp_Object sequence)
2436{ 2439{
2437 register int leni; 2440 register EMACS_INT leni;
2438 2441
2439 leni = XFASTINT (Flength (sequence)); 2442 leni = XFASTINT (Flength (sequence));
2440 if (CHAR_TABLE_P (sequence)) 2443 if (CHAR_TABLE_P (sequence))
@@ -2958,8 +2961,9 @@ static const short base64_char_to_value[128] =
2958 base64 characters. */ 2961 base64 characters. */
2959 2962
2960 2963
2961static int base64_encode_1 (const char *, char *, int, int, int); 2964static EMACS_INT base64_encode_1 (const char *, char *, EMACS_INT, int, int);
2962static int base64_decode_1 (const char *, char *, int, int, int *); 2965static EMACS_INT base64_decode_1 (const char *, char *, EMACS_INT, int,
2966 EMACS_INT *);
2963 2967
2964DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2968DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
2965 2, 3, "r", 2969 2, 3, "r",
@@ -2970,9 +2974,9 @@ into shorter lines. */)
2970 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break) 2974 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break)
2971{ 2975{
2972 char *encoded; 2976 char *encoded;
2973 int allength, length; 2977 EMACS_INT allength, length;
2974 int ibeg, iend, encoded_length; 2978 EMACS_INT ibeg, iend, encoded_length;
2975 int old_pos = PT; 2979 EMACS_INT old_pos = PT;
2976 USE_SAFE_ALLOCA; 2980 USE_SAFE_ALLOCA;
2977 2981
2978 validate_region (&beg, &end); 2982 validate_region (&beg, &end);
@@ -3028,7 +3032,7 @@ Optional second argument NO-LINE-BREAK means do not break long lines
3028into shorter lines. */) 3032into shorter lines. */)
3029 (Lisp_Object string, Lisp_Object no_line_break) 3033 (Lisp_Object string, Lisp_Object no_line_break)
3030{ 3034{
3031 int allength, length, encoded_length; 3035 EMACS_INT allength, length, encoded_length;
3032 char *encoded; 3036 char *encoded;
3033 Lisp_Object encoded_string; 3037 Lisp_Object encoded_string;
3034 USE_SAFE_ALLOCA; 3038 USE_SAFE_ALLOCA;
@@ -3064,10 +3068,12 @@ into shorter lines. */)
3064 return encoded_string; 3068 return encoded_string;
3065} 3069}
3066 3070
3067static int 3071static EMACS_INT
3068base64_encode_1 (const char *from, char *to, int length, int line_break, int multibyte) 3072base64_encode_1 (const char *from, char *to, EMACS_INT length,
3073 int line_break, int multibyte)
3069{ 3074{
3070 int counter = 0, i = 0; 3075 int counter = 0;
3076 EMACS_INT i = 0;
3071 char *e = to; 3077 char *e = to;
3072 int c; 3078 int c;
3073 unsigned int value; 3079 unsigned int value;
@@ -3166,11 +3172,11 @@ Return the length of the decoded text.
3166If the region can't be decoded, signal an error and don't modify the buffer. */) 3172If the region can't be decoded, signal an error and don't modify the buffer. */)
3167 (Lisp_Object beg, Lisp_Object end) 3173 (Lisp_Object beg, Lisp_Object end)
3168{ 3174{
3169 int ibeg, iend, length, allength; 3175 EMACS_INT ibeg, iend, length, allength;
3170 char *decoded; 3176 char *decoded;
3171 int old_pos = PT; 3177 EMACS_INT old_pos = PT;
3172 int decoded_length; 3178 EMACS_INT decoded_length;
3173 int inserted_chars; 3179 EMACS_INT inserted_chars;
3174 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 3180 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
3175 USE_SAFE_ALLOCA; 3181 USE_SAFE_ALLOCA;
3176 3182
@@ -3227,7 +3233,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3227 (Lisp_Object string) 3233 (Lisp_Object string)
3228{ 3234{
3229 char *decoded; 3235 char *decoded;
3230 int length, decoded_length; 3236 EMACS_INT length, decoded_length;
3231 Lisp_Object decoded_string; 3237 Lisp_Object decoded_string;
3232 USE_SAFE_ALLOCA; 3238 USE_SAFE_ALLOCA;
3233 3239
@@ -3259,14 +3265,15 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3259 form. If NCHARS_RETRUN is not NULL, store the number of produced 3265 form. If NCHARS_RETRUN is not NULL, store the number of produced
3260 characters in *NCHARS_RETURN. */ 3266 characters in *NCHARS_RETURN. */
3261 3267
3262static int 3268static EMACS_INT
3263base64_decode_1 (const char *from, char *to, int length, int multibyte, int *nchars_return) 3269base64_decode_1 (const char *from, char *to, EMACS_INT length,
3270 int multibyte, EMACS_INT *nchars_return)
3264{ 3271{
3265 int i = 0; 3272 EMACS_INT i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3266 char *e = to; 3273 char *e = to;
3267 unsigned char c; 3274 unsigned char c;
3268 unsigned long value; 3275 unsigned long value;
3269 int nchars = 0; 3276 EMACS_INT nchars = 0;
3270 3277
3271 while (1) 3278 while (1)
3272 { 3279 {
@@ -4572,13 +4579,13 @@ guesswork fails. Normally, an error is signaled in such case. */)
4572 unsigned char digest[16]; 4579 unsigned char digest[16];
4573 unsigned char value[33]; 4580 unsigned char value[33];
4574 int i; 4581 int i;
4575 int size; 4582 EMACS_INT size;
4576 int size_byte = 0; 4583 EMACS_INT size_byte = 0;
4577 int start_char = 0, end_char = 0; 4584 EMACS_INT start_char = 0, end_char = 0;
4578 int start_byte = 0, end_byte = 0; 4585 EMACS_INT start_byte = 0, end_byte = 0;
4579 register int b, e; 4586 register EMACS_INT b, e;
4580 register struct buffer *bp; 4587 register struct buffer *bp;
4581 int temp; 4588 EMACS_INT temp;
4582 4589
4583 if (STRINGP (object)) 4590 if (STRINGP (object))
4584 { 4591 {
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.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/gnutls.c b/src/gnutls.c
new file mode 100644
index 00000000000..50bf7940119
--- /dev/null
+++ b/src/gnutls.c
@@ -0,0 +1,551 @@
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
35int
36emacs_gnutls_write (int fildes, gnutls_session_t state, char *buf,
37 unsigned int nbyte)
38{
39 register int rtnval, bytes_written;
40
41 bytes_written = 0;
42
43 while (nbyte > 0)
44 {
45 rtnval = gnutls_write (state, buf, nbyte);
46
47 if (rtnval == -1)
48 {
49 if (errno == EINTR)
50 continue;
51 else
52 return (bytes_written ? bytes_written : -1);
53 }
54
55 buf += rtnval;
56 nbyte -= rtnval;
57 bytes_written += rtnval;
58 }
59 fsync (STDOUT_FILENO);
60
61 return (bytes_written);
62}
63
64int
65emacs_gnutls_read (int fildes, gnutls_session_t state, char *buf,
66 unsigned int nbyte)
67{
68 register int rtnval;
69
70 do {
71 rtnval = gnutls_read (state, buf, nbyte);
72 } while (rtnval == GNUTLS_E_INTERRUPTED || rtnval == GNUTLS_E_AGAIN);
73 fsync (STDOUT_FILENO);
74
75 return (rtnval);
76}
77
78/* convert an integer error to a Lisp_Object; it will be either a
79 known symbol like `gnutls_e_interrupted' and `gnutls_e_again' or
80 simply the integer value of the error. GNUTLS_E_SUCCESS is mapped
81 to Qt. */
82Lisp_Object gnutls_make_error (int error)
83{
84 switch (error)
85 {
86 case GNUTLS_E_SUCCESS:
87 return Qt;
88 case GNUTLS_E_AGAIN:
89 return Qgnutls_e_again;
90 case GNUTLS_E_INTERRUPTED:
91 return Qgnutls_e_interrupted;
92 case GNUTLS_E_INVALID_SESSION:
93 return Qgnutls_e_invalid_session;
94 }
95
96 return make_number (error);
97}
98
99DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0,
100 doc: /* Return the GnuTLS init stage of PROCESS.
101See also `gnutls-boot'. */)
102 (Lisp_Object proc)
103{
104 CHECK_PROCESS (proc);
105
106 return make_number (GNUTLS_INITSTAGE (proc));
107}
108
109DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0,
110 doc: /* Returns t if ERROR (as generated by gnutls_make_error)
111indicates a GnuTLS problem. */)
112 (Lisp_Object error)
113{
114 if (EQ (error, Qt)) return Qnil;
115
116 return Qt;
117}
118
119DEFUN ("gnutls-error-fatalp", Fgnutls_error_fatalp, Sgnutls_error_fatalp, 1, 1, 0,
120 doc: /* Checks if ERROR is fatal.
121ERROR is an integer or a symbol with an integer `gnutls-code' property. */)
122 (Lisp_Object err)
123{
124 Lisp_Object code;
125
126 if (EQ (err, Qt)) return Qnil;
127
128 if (SYMBOLP (err))
129 {
130 code = Fget (err, Qgnutls_code);
131 if (NUMBERP (code))
132 {
133 err = code;
134 }
135 else
136 {
137 error ("Symbol has no numeric gnutls-code property");
138 }
139 }
140
141 if (!NUMBERP (err))
142 error ("Not an error symbol or code");
143
144 if (0 == gnutls_error_is_fatal (XINT (err)))
145 return Qnil;
146
147 return Qt;
148}
149
150DEFUN ("gnutls-error-string", Fgnutls_error_string, Sgnutls_error_string, 1, 1, 0,
151 doc: /* Returns a description of ERROR.
152ERROR is an integer or a symbol with an integer `gnutls-code' property. */)
153 (Lisp_Object err)
154{
155 Lisp_Object code;
156
157 if (EQ (err, Qt)) return build_string ("Not an error");
158
159 if (SYMBOLP (err))
160 {
161 code = Fget (err, Qgnutls_code);
162 if (NUMBERP (code))
163 {
164 err = code;
165 }
166 else
167 {
168 return build_string ("Symbol has no numeric gnutls-code property");
169 }
170 }
171
172 if (!NUMBERP (err))
173 return build_string ("Not an error symbol or code");
174
175 return build_string (gnutls_strerror (XINT (err)));
176}
177
178DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0,
179 doc: /* Deallocate GNU TLS resources associated with PROCESS.
180See also `gnutls-init'. */)
181 (Lisp_Object proc)
182{
183 gnutls_session_t state;
184
185 CHECK_PROCESS (proc);
186 state = XPROCESS (proc)->gnutls_state;
187
188 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
189 {
190 gnutls_deinit (state);
191 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1;
192 }
193
194 return Qt;
195}
196
197/* Initializes global GNU TLS state to defaults.
198Call `gnutls-global-deinit' when GNU TLS usage is no longer needed.
199Returns zero on success. */
200Lisp_Object gnutls_emacs_global_init (void)
201{
202 int ret = GNUTLS_E_SUCCESS;
203
204 if (!global_initialized)
205 ret = gnutls_global_init ();
206
207 global_initialized = 1;
208
209 return gnutls_make_error (ret);
210}
211
212/* Deinitializes global GNU TLS state.
213See also `gnutls-global-init'. */
214Lisp_Object gnutls_emacs_global_deinit (void)
215{
216 if (global_initialized)
217 gnutls_global_deinit ();
218
219 global_initialized = 0;
220
221 return gnutls_make_error (GNUTLS_E_SUCCESS);
222}
223
224DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 6, 0,
225 doc: /* Initializes client-mode GnuTLS for process PROC.
226Currently only client mode is supported. Returns a success/failure
227value you can check with `gnutls-errorp'.
228
229PRIORITY_STRING is a string describing the priority.
230TYPE is either `gnutls-anon' or `gnutls-x509pki'.
231TRUSTFILE is a PEM encoded trust file for `gnutls-x509pki'.
232KEYFILE is ... for `gnutls-x509pki' (TODO).
233CALLBACK is ... for `gnutls-x509pki' (TODO).
234
235Note that the priority is set on the client. The server does not use
236the protocols's priority except for disabling protocols that were not
237specified.
238
239Processes must be initialized with this function before other GNU TLS
240functions are used. This function allocates resources which can only
241be deallocated by calling `gnutls-deinit' or by calling it again.
242
243Each authentication type may need additional information in order to
244work. For X.509 PKI (`gnutls-x509pki'), you need TRUSTFILE and
245KEYFILE and optionally CALLBACK. */)
246 (Lisp_Object proc, Lisp_Object priority_string, Lisp_Object type,
247 Lisp_Object trustfile, Lisp_Object keyfile, Lisp_Object callback)
248{
249 int ret = GNUTLS_E_SUCCESS;
250
251 /* TODO: GNUTLS_X509_FMT_DER is also an option. */
252 int file_format = GNUTLS_X509_FMT_PEM;
253
254 gnutls_session_t state;
255 gnutls_certificate_credentials_t x509_cred;
256 gnutls_anon_client_credentials_t anon_cred;
257 gnutls_srp_client_credentials_t srp_cred;
258 gnutls_datum_t data;
259 Lisp_Object global_init;
260
261 CHECK_PROCESS (proc);
262 CHECK_SYMBOL (type);
263 CHECK_STRING (priority_string);
264
265 state = XPROCESS (proc)->gnutls_state;
266
267 /* always initialize globals. */
268 global_init = gnutls_emacs_global_init ();
269 if (! NILP (Fgnutls_errorp (global_init)))
270 return global_init;
271
272 /* deinit and free resources. */
273 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC)
274 {
275 message ("gnutls: deallocating certificates");
276
277 if (EQ (type, Qgnutls_x509pki))
278 {
279 message ("gnutls: deallocating x509 certificates");
280
281 x509_cred = XPROCESS (proc)->x509_cred;
282 gnutls_certificate_free_credentials (x509_cred);
283 }
284 else if (EQ (type, Qgnutls_anon))
285 {
286 message ("gnutls: deallocating anon certificates");
287
288 anon_cred = XPROCESS (proc)->anon_cred;
289 gnutls_anon_free_client_credentials (anon_cred);
290 }
291 else
292 {
293 error ("unknown credential type");
294 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
295 }
296
297 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT)
298 {
299 message ("gnutls: deinitializing");
300
301 Fgnutls_deinit (proc);
302 }
303 }
304
305 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY;
306
307 message ("gnutls: allocating credentials");
308
309 if (EQ (type, Qgnutls_x509pki))
310 {
311 message ("gnutls: allocating x509 credentials");
312
313 x509_cred = XPROCESS (proc)->x509_cred;
314 if (gnutls_certificate_allocate_credentials (&x509_cred) < 0)
315 memory_full ();
316 }
317 else if (EQ (type, Qgnutls_anon))
318 {
319 message ("gnutls: allocating anon credentials");
320
321 anon_cred = XPROCESS (proc)->anon_cred;
322 if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0)
323 memory_full ();
324 }
325 else
326 {
327 error ("unknown credential type");
328 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
329 }
330
331 if (ret < GNUTLS_E_SUCCESS)
332 return gnutls_make_error (ret);
333
334 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC;
335
336 message ("gnutls: setting the trustfile");
337
338 if (EQ (type, Qgnutls_x509pki))
339 {
340 if (STRINGP (trustfile))
341 {
342 ret = gnutls_certificate_set_x509_trust_file
343 (x509_cred,
344 XSTRING (trustfile)->data,
345 file_format);
346
347 if (ret < GNUTLS_E_SUCCESS)
348 return gnutls_make_error (ret);
349
350 message ("gnutls: processed %d CA certificates", ret);
351 }
352
353 message ("gnutls: setting the keyfile");
354
355 if (STRINGP (keyfile))
356 {
357 ret = gnutls_certificate_set_x509_crl_file
358 (x509_cred,
359 XSTRING (keyfile)->data,
360 file_format);
361
362 if (ret < GNUTLS_E_SUCCESS)
363 return gnutls_make_error (ret);
364
365 message ("gnutls: processed %d CRL(s)", ret);
366 }
367 }
368
369 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES;
370
371 message ("gnutls: gnutls_init");
372
373 ret = gnutls_init (&state, GNUTLS_CLIENT);
374
375 if (ret < GNUTLS_E_SUCCESS)
376 return gnutls_make_error (ret);
377
378 XPROCESS (proc)->gnutls_state = state;
379
380 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT;
381
382 message ("gnutls: setting the priority string");
383
384 ret = gnutls_priority_set_direct(state,
385 (char*) SDATA (priority_string),
386 NULL);
387
388 if (ret < GNUTLS_E_SUCCESS)
389 return gnutls_make_error (ret);
390
391 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY;
392
393 message ("gnutls: setting the credentials");
394
395 if (EQ (type, Qgnutls_x509pki))
396 {
397 message ("gnutls: setting the x509 credentials");
398
399 ret = gnutls_cred_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred);
400 }
401 else if (EQ (type, Qgnutls_anon))
402 {
403 message ("gnutls: setting the anon credentials");
404
405 ret = gnutls_cred_set (state, GNUTLS_CRD_ANON, anon_cred);
406 }
407 else
408 {
409 error ("unknown credential type");
410 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE;
411 }
412
413 if (ret < GNUTLS_E_SUCCESS)
414 return gnutls_make_error (ret);
415
416 XPROCESS (proc)->anon_cred = anon_cred;
417 XPROCESS (proc)->x509_cred = x509_cred;
418 XPROCESS (proc)->gnutls_cred_type = type;
419
420 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET;
421
422 return gnutls_make_error (GNUTLS_E_SUCCESS);
423}
424
425DEFUN ("gnutls-bye", Fgnutls_bye,
426 Sgnutls_bye, 2, 2, 0,
427 doc: /* Terminate current GNU TLS connection for PROCESS.
428The connection should have been initiated using `gnutls-handshake'.
429
430If CONT is not nil the TLS connection gets terminated and further
431receives and sends will be disallowed. If the return value is zero you
432may continue using the connection. If CONT is nil, GnuTLS actually
433sends an alert containing a close request and waits for the peer to
434reply with the same message. In order to reuse the connection you
435should wait for an EOF from the peer.
436
437This function may also return `gnutls-e-again', or
438`gnutls-e-interrupted'. */)
439 (Lisp_Object proc, Lisp_Object cont)
440{
441 gnutls_session_t state;
442 int ret;
443
444 CHECK_PROCESS (proc);
445
446 state = XPROCESS (proc)->gnutls_state;
447
448 ret = gnutls_bye (state,
449 NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR);
450
451 return gnutls_make_error (ret);
452}
453
454DEFUN ("gnutls-handshake", Fgnutls_handshake,
455 Sgnutls_handshake, 1, 1, 0,
456 doc: /* Perform GNU TLS handshake for PROCESS.
457The identity of the peer is checked automatically. This function will
458fail if any problem is encountered, and will return a negative error
459code. In case of a client, if it has been asked to resume a session,
460but the server didn't, then a full handshake will be performed.
461
462If the error `gnutls-e-not-ready-for-handshake' is returned, you
463didn't call `gnutls-boot' first.
464
465This function may also return the non-fatal errors `gnutls-e-again',
466or `gnutls-e-interrupted'. In that case you may resume the handshake
467(by calling this function again). */)
468 (Lisp_Object proc)
469{
470 gnutls_session_t state;
471 int ret;
472
473 CHECK_PROCESS (proc);
474 state = XPROCESS (proc)->gnutls_state;
475
476 if (GNUTLS_INITSTAGE (proc) < GNUTLS_STAGE_HANDSHAKE_CANDO)
477 return Qgnutls_e_not_ready_for_handshake;
478
479
480 if (GNUTLS_INITSTAGE (proc) < GNUTLS_STAGE_TRANSPORT_POINTERS_SET)
481 {
482 /* for a network process in Emacs infd and outfd are the same
483 but this shows our intent more clearly. */
484 message ("gnutls: handshake: setting the transport pointers to %d/%d",
485 XPROCESS (proc)->infd, XPROCESS (proc)->outfd);
486
487 gnutls_transport_set_ptr2 (state, XPROCESS (proc)->infd,
488 XPROCESS (proc)->outfd);
489
490 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_TRANSPORT_POINTERS_SET;
491 }
492
493 message ("gnutls: handshake: handshaking");
494 ret = gnutls_handshake (state);
495
496 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_HANDSHAKE_TRIED;
497
498 if (GNUTLS_E_SUCCESS == ret)
499 {
500 /* here we're finally done. */
501 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_READY;
502 }
503
504 return gnutls_make_error (ret);
505}
506
507void
508syms_of_gnutls (void)
509{
510 global_initialized = 0;
511
512 Qgnutls_code = intern_c_string ("gnutls-code");
513 staticpro (&Qgnutls_code);
514
515 Qgnutls_anon = intern_c_string ("gnutls-anon");
516 staticpro (&Qgnutls_anon);
517
518 Qgnutls_x509pki = intern_c_string ("gnutls-x509pki");
519 staticpro (&Qgnutls_x509pki);
520
521 Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted");
522 staticpro (&Qgnutls_e_interrupted);
523 Fput (Qgnutls_e_interrupted, Qgnutls_code,
524 make_number (GNUTLS_E_INTERRUPTED));
525
526 Qgnutls_e_again = intern_c_string ("gnutls-e-again");
527 staticpro (&Qgnutls_e_again);
528 Fput (Qgnutls_e_again, Qgnutls_code,
529 make_number (GNUTLS_E_AGAIN));
530
531 Qgnutls_e_invalid_session = intern_c_string ("gnutls-e-invalid-session");
532 staticpro (&Qgnutls_e_invalid_session);
533 Fput (Qgnutls_e_invalid_session, Qgnutls_code,
534 make_number (GNUTLS_E_INVALID_SESSION));
535
536 Qgnutls_e_not_ready_for_handshake =
537 intern_c_string ("gnutls-e-not-ready-for-handshake");
538 staticpro (&Qgnutls_e_not_ready_for_handshake);
539 Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code,
540 make_number (GNUTLS_E_APPLICATION_ERROR_MIN));
541
542 defsubr (&Sgnutls_get_initstage);
543 defsubr (&Sgnutls_errorp);
544 defsubr (&Sgnutls_error_fatalp);
545 defsubr (&Sgnutls_error_string);
546 defsubr (&Sgnutls_boot);
547 defsubr (&Sgnutls_deinit);
548 defsubr (&Sgnutls_handshake);
549 defsubr (&Sgnutls_bye);
550}
551#endif
diff --git a/src/gnutls.h b/src/gnutls.h
new file mode 100644
index 00000000000..3a9030ba454
--- /dev/null
+++ b/src/gnutls.h
@@ -0,0 +1,60 @@
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
49int
50emacs_gnutls_write (int fildes, gnutls_session_t state, char *buf,
51 unsigned int nbyte);
52int
53emacs_gnutls_read (int fildes, gnutls_session_t state, char *buf,
54 unsigned int nbyte);
55
56extern void syms_of_gnutls (void);
57
58#endif
59
60#endif
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9356250eb71..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;
diff --git a/src/image.c b/src/image.c
index ff0bbc1d688..940959e951a 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 eed031a3c2e..1be6c2aad9d 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 {
@@ -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 781261d9779..f1d4dd9a330 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -739,7 +739,7 @@ struct Lisp_Cons
739#ifdef GC_CHECK_STRING_BYTES 739#ifdef GC_CHECK_STRING_BYTES
740 740
741struct Lisp_String; 741struct Lisp_String;
742extern int string_bytes (struct Lisp_String *); 742extern EMACS_INT string_bytes (struct Lisp_String *);
743#define STRING_BYTES(S) string_bytes ((S)) 743#define STRING_BYTES(S) string_bytes ((S))
744 744
745#else /* not GC_CHECK_STRING_BYTES */ 745#else /* not GC_CHECK_STRING_BYTES */
@@ -1877,11 +1877,11 @@ struct specbinding
1877 1877
1878extern struct specbinding *specpdl; 1878extern struct specbinding *specpdl;
1879extern struct specbinding *specpdl_ptr; 1879extern struct specbinding *specpdl_ptr;
1880extern int specpdl_size; 1880extern EMACS_INT specpdl_size;
1881 1881
1882extern EMACS_INT max_specpdl_size; 1882extern EMACS_INT max_specpdl_size;
1883 1883
1884#define SPECPDL_INDEX() (specpdl_ptr - specpdl) 1884#define SPECPDL_INDEX() ((int) (specpdl_ptr - specpdl))
1885 1885
1886/* Everything needed to describe an active condition case. */ 1886/* Everything needed to describe an active condition case. */
1887struct handler 1887struct handler
@@ -2495,7 +2495,8 @@ EXFUN (Fstring_as_unibyte, 1);
2495EXFUN (Fstring_to_multibyte, 1); 2495EXFUN (Fstring_to_multibyte, 1);
2496EXFUN (Fstring_to_unibyte, 1); 2496EXFUN (Fstring_to_unibyte, 1);
2497EXFUN (Fsubstring, 3); 2497EXFUN (Fsubstring, 3);
2498extern Lisp_Object substring_both (Lisp_Object, int, int, int, int); 2498extern Lisp_Object substring_both (Lisp_Object, EMACS_INT, EMACS_INT,
2499 EMACS_INT, EMACS_INT);
2499EXFUN (Fnth, 2); 2500EXFUN (Fnth, 2);
2500EXFUN (Fnthcdr, 2); 2501EXFUN (Fnthcdr, 2);
2501EXFUN (Fmemq, 2); 2502EXFUN (Fmemq, 2);
@@ -2666,14 +2667,14 @@ extern void message2 (const char *, int, int);
2666extern void message2_nolog (const char *, int, int); 2667extern void message2_nolog (const char *, int, int);
2667extern void message3 (Lisp_Object, int, int); 2668extern void message3 (Lisp_Object, int, int);
2668extern void message3_nolog (Lisp_Object, int, int); 2669extern void message3_nolog (Lisp_Object, int, int);
2669extern void message_dolog (const char *, int, int, int); 2670extern void message_dolog (const char *, EMACS_INT, int, int);
2670extern void message_with_string (const char *, Lisp_Object, int); 2671extern void message_with_string (const char *, Lisp_Object, int);
2671extern void message_log_maybe_newline (void); 2672extern void message_log_maybe_newline (void);
2672extern void update_echo_area (void); 2673extern void update_echo_area (void);
2673extern void truncate_echo_area (int); 2674extern void truncate_echo_area (EMACS_INT);
2674extern void redisplay (void); 2675extern void redisplay (void);
2675extern int check_point_in_composition 2676extern int check_point_in_composition
2676 (struct buffer *, int, struct buffer *, int); 2677 (struct buffer *, EMACS_INT, struct buffer *, EMACS_INT);
2677extern void redisplay_preserve_echo_area (int); 2678extern void redisplay_preserve_echo_area (int);
2678extern void prepare_menu_bars (void); 2679extern void prepare_menu_bars (void);
2679 2680
@@ -2692,7 +2693,7 @@ extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (const char *));
2692 2693
2693/* Defined in alloc.c */ 2694/* Defined in alloc.c */
2694extern void check_pure_size (void); 2695extern void check_pure_size (void);
2695extern void allocate_string_data (struct Lisp_String *, int, int); 2696extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
2696extern void reset_malloc_hooks (void); 2697extern void reset_malloc_hooks (void);
2697extern void uninterrupt_malloc (void); 2698extern void uninterrupt_malloc (void);
2698extern void malloc_warning (const char *); 2699extern void malloc_warning (const char *);
@@ -2718,16 +2719,17 @@ EXFUN (Fmake_symbol, 1);
2718EXFUN (Fmake_marker, 0); 2719EXFUN (Fmake_marker, 0);
2719EXFUN (Fmake_string, 2); 2720EXFUN (Fmake_string, 2);
2720extern Lisp_Object build_string (const char *); 2721extern Lisp_Object build_string (const char *);
2721extern Lisp_Object make_string (const char *, int); 2722extern Lisp_Object make_string (const char *, EMACS_INT);
2722extern Lisp_Object make_unibyte_string (const char *, int); 2723extern Lisp_Object make_unibyte_string (const char *, EMACS_INT);
2723extern Lisp_Object make_multibyte_string (const char *, int, int); 2724extern Lisp_Object make_multibyte_string (const char *, EMACS_INT, EMACS_INT);
2724extern Lisp_Object make_event_array (int, Lisp_Object *); 2725extern Lisp_Object make_event_array (int, Lisp_Object *);
2725extern Lisp_Object make_uninit_string (int); 2726extern Lisp_Object make_uninit_string (EMACS_INT);
2726extern Lisp_Object make_uninit_multibyte_string (int, int); 2727extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT);
2727extern Lisp_Object make_string_from_bytes (const char *, int, int); 2728extern Lisp_Object make_string_from_bytes (const char *, EMACS_INT, EMACS_INT);
2728extern Lisp_Object make_specified_string (const char *, int, int, int); 2729extern Lisp_Object make_specified_string (const char *,
2730 EMACS_INT, EMACS_INT, int);
2729EXFUN (Fpurecopy, 1); 2731EXFUN (Fpurecopy, 1);
2730extern Lisp_Object make_pure_string (const char *, int, int, int); 2732extern Lisp_Object make_pure_string (const char *, EMACS_INT, EMACS_INT, int);
2731extern Lisp_Object make_pure_c_string (const char *data); 2733extern Lisp_Object make_pure_c_string (const char *data);
2732extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); 2734extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
2733extern Lisp_Object make_pure_vector (EMACS_INT); 2735extern Lisp_Object make_pure_vector (EMACS_INT);
@@ -2815,7 +2817,7 @@ extern void float_to_string (unsigned char *, double);
2815extern void syms_of_print (void); 2817extern void syms_of_print (void);
2816 2818
2817/* Defined in doprnt.c */ 2819/* Defined in doprnt.c */
2818extern int doprnt (char *, int, const char *, const char *, va_list); 2820extern EMACS_INT doprnt (char *, int, const char *, const char *, va_list);
2819 2821
2820/* Defined in lread.c */ 2822/* Defined in lread.c */
2821extern Lisp_Object Vafter_load_alist; 2823extern Lisp_Object Vafter_load_alist;
@@ -2838,7 +2840,7 @@ extern Lisp_Object check_obarray (Lisp_Object);
2838extern Lisp_Object intern (const char *); 2840extern Lisp_Object intern (const char *);
2839extern Lisp_Object intern_c_string (const char *); 2841extern Lisp_Object intern_c_string (const char *);
2840extern Lisp_Object make_symbol (const char *); 2842extern Lisp_Object make_symbol (const char *);
2841extern Lisp_Object oblookup (Lisp_Object, const char *, int, int); 2843extern Lisp_Object oblookup (Lisp_Object, const char *, EMACS_INT, EMACS_INT);
2842#define LOADHIST_ATTACH(x) \ 2844#define LOADHIST_ATTACH(x) \
2843 do { \ 2845 do { \
2844 if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \ 2846 if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \
@@ -2990,9 +2992,10 @@ EXFUN (Fwiden, 0);
2990EXFUN (Fuser_login_name, 1); 2992EXFUN (Fuser_login_name, 1);
2991EXFUN (Fsystem_name, 0); 2993EXFUN (Fsystem_name, 0);
2992EXFUN (Fcurrent_time, 0); 2994EXFUN (Fcurrent_time, 0);
2993extern int clip_to_bounds (int, int, int); 2995extern EMACS_INT clip_to_bounds (EMACS_INT, EMACS_INT, EMACS_INT);
2994extern Lisp_Object make_buffer_string (int, int, int); 2996extern Lisp_Object make_buffer_string (EMACS_INT, EMACS_INT, int);
2995extern Lisp_Object make_buffer_string_both (int, int, int, int, int); 2997extern Lisp_Object make_buffer_string_both (EMACS_INT, EMACS_INT, EMACS_INT,
2998 EMACS_INT, int);
2996extern void init_editfns (void); 2999extern void init_editfns (void);
2997extern void syms_of_editfns (void); 3000extern void syms_of_editfns (void);
2998EXFUN (Fconstrain_to_field, 5); 3001EXFUN (Fconstrain_to_field, 5);
@@ -3012,10 +3015,10 @@ EXFUN (Foverlay_end, 1);
3012EXFUN (Foverlay_buffer, 1); 3015EXFUN (Foverlay_buffer, 1);
3013extern void adjust_overlays_for_insert (EMACS_INT, EMACS_INT); 3016extern void adjust_overlays_for_insert (EMACS_INT, EMACS_INT);
3014extern void adjust_overlays_for_delete (EMACS_INT, EMACS_INT); 3017extern void adjust_overlays_for_delete (EMACS_INT, EMACS_INT);
3015extern void fix_start_end_in_overlays (int, int); 3018extern void fix_start_end_in_overlays (EMACS_INT, EMACS_INT);
3016extern void report_overlay_modification (Lisp_Object, Lisp_Object, int, 3019extern void report_overlay_modification (Lisp_Object, Lisp_Object, int,
3017 Lisp_Object, Lisp_Object, Lisp_Object); 3020 Lisp_Object, Lisp_Object, Lisp_Object);
3018extern int overlay_touches_p (int); 3021extern int overlay_touches_p (EMACS_INT);
3019extern Lisp_Object Vbuffer_alist, Vinhibit_read_only; 3022extern Lisp_Object Vbuffer_alist, Vinhibit_read_only;
3020EXFUN (Fbuffer_list, 1); 3023EXFUN (Fbuffer_list, 1);
3021EXFUN (Fget_buffer, 1); 3024EXFUN (Fget_buffer, 1);
@@ -3052,17 +3055,17 @@ EXFUN (Fmarker_position, 1);
3052EXFUN (Fmarker_buffer, 1); 3055EXFUN (Fmarker_buffer, 1);
3053EXFUN (Fcopy_marker, 2); 3056EXFUN (Fcopy_marker, 2);
3054EXFUN (Fset_marker, 3); 3057EXFUN (Fset_marker, 3);
3055extern int marker_position (Lisp_Object); 3058extern EMACS_INT marker_position (Lisp_Object);
3056extern int marker_byte_position (Lisp_Object); 3059extern EMACS_INT marker_byte_position (Lisp_Object);
3057extern void clear_charpos_cache (struct buffer *); 3060extern void clear_charpos_cache (struct buffer *);
3058extern int charpos_to_bytepos (int); 3061extern EMACS_INT charpos_to_bytepos (EMACS_INT);
3059extern int buf_charpos_to_bytepos (struct buffer *, int); 3062extern EMACS_INT buf_charpos_to_bytepos (struct buffer *, EMACS_INT);
3060extern int buf_bytepos_to_charpos (struct buffer *, int); 3063extern EMACS_INT buf_bytepos_to_charpos (struct buffer *, EMACS_INT);
3061extern void unchain_marker (struct Lisp_Marker *marker); 3064extern void unchain_marker (struct Lisp_Marker *marker);
3062extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); 3065extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object);
3063extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, int, int); 3066extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT);
3064extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, 3067extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
3065 int, int); 3068 EMACS_INT, EMACS_INT);
3066extern void syms_of_marker (void); 3069extern void syms_of_marker (void);
3067 3070
3068/* Defined in fileio.c */ 3071/* Defined in fileio.c */
@@ -3120,12 +3123,13 @@ extern int fast_c_string_match_ignore_case (Lisp_Object, const char *);
3120extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object); 3123extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
3121extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT, 3124extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT,
3122 EMACS_INT, EMACS_INT, Lisp_Object); 3125 EMACS_INT, EMACS_INT, Lisp_Object);
3123extern int scan_buffer (int, EMACS_INT, EMACS_INT, int, int *, int); 3126extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT,
3124extern int scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, 3127 int *, int);
3125 int, int); 3128extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
3126extern int find_next_newline (EMACS_INT, int); 3129 EMACS_INT, int);
3127extern int find_next_newline_no_quit (EMACS_INT, int); 3130extern EMACS_INT find_next_newline (EMACS_INT, int);
3128extern int find_before_next_newline (EMACS_INT, EMACS_INT, int); 3131extern EMACS_INT find_next_newline_no_quit (EMACS_INT, EMACS_INT);
3132extern EMACS_INT find_before_next_newline (EMACS_INT, EMACS_INT, EMACS_INT);
3129extern void syms_of_search (void); 3133extern void syms_of_search (void);
3130extern void clear_regexp_cache (void); 3134extern void clear_regexp_cache (void);
3131 3135
@@ -3237,7 +3241,7 @@ EXFUN (Fcurrent_column, 0);
3237EXFUN (Fmove_to_column, 2); 3241EXFUN (Fmove_to_column, 2);
3238extern double current_column (void); 3242extern double current_column (void);
3239extern void invalidate_current_column (void); 3243extern void invalidate_current_column (void);
3240extern int indented_beyond_p (int, int, double); 3244extern int indented_beyond_p (EMACS_INT, EMACS_INT, double);
3241extern void syms_of_indent (void); 3245extern void syms_of_indent (void);
3242 3246
3243/* Defined in frame.c */ 3247/* Defined in frame.c */
@@ -3392,12 +3396,13 @@ extern Lisp_Object Qapply;
3392extern Lisp_Object Qinhibit_read_only; 3396extern Lisp_Object Qinhibit_read_only;
3393EXFUN (Fundo_boundary, 0); 3397EXFUN (Fundo_boundary, 0);
3394extern void truncate_undo_list (struct buffer *); 3398extern void truncate_undo_list (struct buffer *);
3395extern void record_marker_adjustment (Lisp_Object, int); 3399extern void record_marker_adjustment (Lisp_Object, EMACS_INT);
3396extern void record_insert (int, int); 3400extern void record_insert (EMACS_INT, EMACS_INT);
3397extern void record_delete (int, Lisp_Object); 3401extern void record_delete (EMACS_INT, Lisp_Object);
3398extern void record_first_change (void); 3402extern void record_first_change (void);
3399extern void record_change (int, int); 3403extern void record_change (EMACS_INT, EMACS_INT);
3400extern void record_property_change (int, int, Lisp_Object, Lisp_Object, 3404extern void record_property_change (EMACS_INT, EMACS_INT,
3405 Lisp_Object, Lisp_Object,
3401 Lisp_Object); 3406 Lisp_Object);
3402extern void syms_of_undo (void); 3407extern void syms_of_undo (void);
3403extern Lisp_Object Vundo_outer_limit; 3408extern Lisp_Object Vundo_outer_limit;
@@ -3722,7 +3727,7 @@ extern void init_system_name (void);
3722extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3727extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3723 3728
3724#define USE_SAFE_ALLOCA \ 3729#define USE_SAFE_ALLOCA \
3725 int sa_count = SPECPDL_INDEX (), sa_must_free = 0 3730 int sa_count = (int) SPECPDL_INDEX (), sa_must_free = 0
3726 3731
3727/* SAFE_ALLOCA allocates a simple buffer. */ 3732/* SAFE_ALLOCA allocates a simple buffer. */
3728 3733
diff --git a/src/lread.c b/src/lread.c
index b616e30c3c6..81b7082204c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -163,13 +163,13 @@ static FILE *instream;
163static int read_pure; 163static int read_pure;
164 164
165/* For use within read-from-string (this reader is non-reentrant!!) */ 165/* For use within read-from-string (this reader is non-reentrant!!) */
166static int read_from_string_index; 166static EMACS_INT read_from_string_index;
167static int read_from_string_index_byte; 167static EMACS_INT read_from_string_index_byte;
168static int read_from_string_limit; 168static EMACS_INT read_from_string_limit;
169 169
170/* Number of characters read in the current call to Fread or 170/* Number of characters read in the current call to Fread or
171 Fread_from_string. */ 171 Fread_from_string. */
172static int readchar_count; 172static EMACS_INT readchar_count;
173 173
174/* This contains the last string skipped with #@. */ 174/* This contains the last string skipped with #@. */
175static char *saved_doc_string; 175static char *saved_doc_string;
@@ -276,7 +276,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
276 { 276 {
277 register struct buffer *inbuffer = XBUFFER (readcharfun); 277 register struct buffer *inbuffer = XBUFFER (readcharfun);
278 278
279 int pt_byte = BUF_PT_BYTE (inbuffer); 279 EMACS_INT pt_byte = BUF_PT_BYTE (inbuffer);
280 280
281 if (pt_byte >= BUF_ZV_BYTE (inbuffer)) 281 if (pt_byte >= BUF_ZV_BYTE (inbuffer))
282 return -1; 282 return -1;
@@ -305,7 +305,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
305 { 305 {
306 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; 306 register struct buffer *inbuffer = XMARKER (readcharfun)->buffer;
307 307
308 int bytepos = marker_byte_position (readcharfun); 308 EMACS_INT bytepos = marker_byte_position (readcharfun);
309 309
310 if (bytepos >= BUF_ZV_BYTE (inbuffer)) 310 if (bytepos >= BUF_ZV_BYTE (inbuffer))
311 return -1; 311 return -1;
@@ -439,7 +439,7 @@ unreadchar (Lisp_Object readcharfun, int c)
439 else if (BUFFERP (readcharfun)) 439 else if (BUFFERP (readcharfun))
440 { 440 {
441 struct buffer *b = XBUFFER (readcharfun); 441 struct buffer *b = XBUFFER (readcharfun);
442 int bytepos = BUF_PT_BYTE (b); 442 EMACS_INT bytepos = BUF_PT_BYTE (b);
443 443
444 BUF_PT (b)--; 444 BUF_PT (b)--;
445 if (! NILP (b->enable_multibyte_characters)) 445 if (! NILP (b->enable_multibyte_characters))
@@ -452,7 +452,7 @@ unreadchar (Lisp_Object readcharfun, int c)
452 else if (MARKERP (readcharfun)) 452 else if (MARKERP (readcharfun))
453 { 453 {
454 struct buffer *b = XMARKER (readcharfun)->buffer; 454 struct buffer *b = XMARKER (readcharfun)->buffer;
455 int bytepos = XMARKER (readcharfun)->bytepos; 455 EMACS_INT bytepos = XMARKER (readcharfun)->bytepos;
456 456
457 XMARKER (readcharfun)->charpos--; 457 XMARKER (readcharfun)->charpos--;
458 if (! NILP (b->enable_multibyte_characters)) 458 if (! NILP (b->enable_multibyte_characters))
@@ -1893,7 +1893,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
1893 if (STRINGP (stream) 1893 if (STRINGP (stream)
1894 || ((CONSP (stream) && STRINGP (XCAR (stream))))) 1894 || ((CONSP (stream) && STRINGP (XCAR (stream)))))
1895 { 1895 {
1896 int startval, endval; 1896 EMACS_INT startval, endval;
1897 Lisp_Object string; 1897 Lisp_Object string;
1898 1898
1899 if (STRINGP (stream)) 1899 if (STRINGP (stream))
@@ -3739,7 +3739,7 @@ OBARRAY defaults to the value of the variable `obarray'. */)
3739 Also store the bucket number in oblookup_last_bucket_number. */ 3739 Also store the bucket number in oblookup_last_bucket_number. */
3740 3740
3741Lisp_Object 3741Lisp_Object
3742oblookup (Lisp_Object obarray, register const char *ptr, int size, int size_byte) 3742oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte)
3743{ 3743{
3744 int hash; 3744 int hash;
3745 int obsize; 3745 int obsize;
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 1df11447d0d..46132ff1e47 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)
diff --git a/src/process.c b/src/process.c
index ec1b9586db5..70cc8250add 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,10 @@ 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#endif
675
586 /* If name is already in use, modify it until it is unused. */ 676 /* If name is already in use, modify it until it is unused. */
587 677
588 name1 = name; 678 name1 = name;
@@ -1526,6 +1616,12 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1526 XPROCESS (proc)->filter = Qnil; 1616 XPROCESS (proc)->filter = Qnil;
1527 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); 1617 XPROCESS (proc)->command = Flist (nargs - 2, args + 2);
1528 1618
1619#ifdef HAVE_GNUTLS
1620 /* AKA GNUTLS_INITSTAGE(proc). */
1621 XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY;
1622 XPROCESS (proc)->gnutls_cred_type = Qnil;
1623#endif
1624
1529#ifdef ADAPTIVE_READ_BUFFERING 1625#ifdef ADAPTIVE_READ_BUFFERING
1530 XPROCESS (proc)->adaptive_read_buffering 1626 XPROCESS (proc)->adaptive_read_buffering
1531 = (NILP (Vprocess_adaptive_read_buffering) ? 0 1627 = (NILP (Vprocess_adaptive_read_buffering) ? 0
@@ -3170,7 +3266,9 @@ usage: (make-network-process &rest ARGS) */)
3170 if (!NILP (host)) 3266 if (!NILP (host))
3171 { 3267 {
3172 if (EQ (host, Qlocal)) 3268 if (EQ (host, Qlocal))
3173 host = build_string ("localhost"); 3269 /* Depending on setup, "localhost" may map to different IPv4 and/or
3270 IPv6 addresses, so it's better to be explicit. (Bug#6781) */
3271 host = build_string ("127.0.0.1");
3174 CHECK_STRING (host); 3272 CHECK_STRING (host);
3175 } 3273 }
3176 3274
@@ -3605,6 +3703,7 @@ usage: (make-network-process &rest ARGS) */)
3605 if (!FD_ISSET (inch, &connect_wait_mask)) 3703 if (!FD_ISSET (inch, &connect_wait_mask))
3606 { 3704 {
3607 FD_SET (inch, &connect_wait_mask); 3705 FD_SET (inch, &connect_wait_mask);
3706 FD_SET (inch, &write_mask);
3608 num_pending_connects++; 3707 num_pending_connects++;
3609 } 3708 }
3610 } 3709 }
@@ -4008,6 +4107,7 @@ deactivate_process (Lisp_Object proc)
4008 if (FD_ISSET (inchannel, &connect_wait_mask)) 4107 if (FD_ISSET (inchannel, &connect_wait_mask))
4009 { 4108 {
4010 FD_CLR (inchannel, &connect_wait_mask); 4109 FD_CLR (inchannel, &connect_wait_mask);
4110 FD_CLR (inchannel, &write_mask);
4011 if (--num_pending_connects < 0) 4111 if (--num_pending_connects < 0)
4012 abort (); 4112 abort ();
4013 } 4113 }
@@ -4386,10 +4486,8 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4386{ 4486{
4387 register int channel, nfds; 4487 register int channel, nfds;
4388 SELECT_TYPE Available; 4488 SELECT_TYPE Available;
4389#ifdef NON_BLOCKING_CONNECT 4489 SELECT_TYPE Writeok;
4390 SELECT_TYPE Connecting; 4490 int check_write;
4391 int check_connect;
4392#endif
4393 int check_delay, no_avail; 4491 int check_delay, no_avail;
4394 int xerrno; 4492 int xerrno;
4395 Lisp_Object proc; 4493 Lisp_Object proc;
@@ -4399,9 +4497,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4399 int count = SPECPDL_INDEX (); 4497 int count = SPECPDL_INDEX ();
4400 4498
4401 FD_ZERO (&Available); 4499 FD_ZERO (&Available);
4402#ifdef NON_BLOCKING_CONNECT 4500 FD_ZERO (&Writeok);
4403 FD_ZERO (&Connecting);
4404#endif
4405 4501
4406 if (time_limit == 0 && microsecs == 0 && wait_proc && !NILP (Vinhibit_quit) 4502 if (time_limit == 0 && microsecs == 0 && wait_proc && !NILP (Vinhibit_quit)
4407 && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit))) 4503 && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit)))
@@ -4537,19 +4633,16 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4537 if (update_tick != process_tick) 4633 if (update_tick != process_tick)
4538 { 4634 {
4539 SELECT_TYPE Atemp; 4635 SELECT_TYPE Atemp;
4540#ifdef NON_BLOCKING_CONNECT
4541 SELECT_TYPE Ctemp; 4636 SELECT_TYPE Ctemp;
4542#endif
4543 4637
4544 if (kbd_on_hold_p ()) 4638 if (kbd_on_hold_p ())
4545 FD_ZERO (&Atemp); 4639 FD_ZERO (&Atemp);
4546 else 4640 else
4547 Atemp = input_wait_mask; 4641 Atemp = input_wait_mask;
4548 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); 4642 Ctemp = write_mask;
4549 4643
4550 EMACS_SET_SECS_USECS (timeout, 0, 0); 4644 EMACS_SET_SECS_USECS (timeout, 0, 0);
4551 if ((select (max (max (max_process_desc, max_keyboard_desc), 4645 if ((select (max (max_process_desc, max_input_desc) + 1,
4552 max_gpm_desc) + 1,
4553 &Atemp, 4646 &Atemp,
4554#ifdef NON_BLOCKING_CONNECT 4647#ifdef NON_BLOCKING_CONNECT
4555 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), 4648 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
@@ -4620,13 +4713,13 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4620 break; 4713 break;
4621 FD_SET (wait_proc->infd, &Available); 4714 FD_SET (wait_proc->infd, &Available);
4622 check_delay = 0; 4715 check_delay = 0;
4623 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4716 check_write = 0;
4624 } 4717 }
4625 else if (!NILP (wait_for_cell)) 4718 else if (!NILP (wait_for_cell))
4626 { 4719 {
4627 Available = non_process_wait_mask; 4720 Available = non_process_wait_mask;
4628 check_delay = 0; 4721 check_delay = 0;
4629 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4722 check_write = 0;
4630 } 4723 }
4631 else 4724 else
4632 { 4725 {
@@ -4634,7 +4727,12 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4634 Available = non_keyboard_wait_mask; 4727 Available = non_keyboard_wait_mask;
4635 else 4728 else
4636 Available = input_wait_mask; 4729 Available = input_wait_mask;
4637 IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0)); 4730 Writeok = write_mask;
4731#ifdef SELECT_CANT_DO_WRITE_MASK
4732 check_write = 0;
4733#else
4734 check_write = 1;
4735#endif
4638 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; 4736 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count;
4639 } 4737 }
4640 4738
@@ -4659,10 +4757,6 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4659 } 4757 }
4660 else 4758 else
4661 { 4759 {
4662#ifdef NON_BLOCKING_CONNECT
4663 if (check_connect)
4664 Connecting = connect_wait_mask;
4665#endif
4666 4760
4667#ifdef ADAPTIVE_READ_BUFFERING 4761#ifdef ADAPTIVE_READ_BUFFERING
4668 /* Set the timeout for adaptive read buffering if any 4762 /* Set the timeout for adaptive read buffering if any
@@ -4704,15 +4798,10 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4704#else 4798#else
4705 nfds = select 4799 nfds = select
4706#endif 4800#endif
4707 (max (max (max_process_desc, max_keyboard_desc), 4801 (max (max_process_desc, max_input_desc) + 1,
4708 max_gpm_desc) + 1, 4802 &Available,
4709 &Available, 4803 (check_write ? &Writeok : (SELECT_TYPE *)0),
4710#ifdef NON_BLOCKING_CONNECT 4804 (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 } 4805 }
4717 4806
4718 xerrno = errno; 4807 xerrno = errno;
@@ -4752,7 +4841,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4752 if (no_avail) 4841 if (no_avail)
4753 { 4842 {
4754 FD_ZERO (&Available); 4843 FD_ZERO (&Available);
4755 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4844 check_write = 0;
4756 } 4845 }
4757 4846
4758#if 0 /* When polling is used, interrupt_input is 0, 4847#if 0 /* When polling is used, interrupt_input is 0,
@@ -4848,12 +4937,26 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4848 if (no_avail || nfds == 0) 4937 if (no_avail || nfds == 0)
4849 continue; 4938 continue;
4850 4939
4940 for (channel = 0; channel <= max_input_desc; ++channel)
4941 {
4942 struct fd_callback_data *d = &fd_callback_info[channel];
4943 if (FD_ISSET (channel, &Available)
4944 && d->func != 0
4945 && (d->condition & FOR_READ) != 0)
4946 d->func (channel, d->data, 1);
4947 if (FD_ISSET (channel, &write_mask)
4948 && d->func != 0
4949 && (d->condition & FOR_WRITE) != 0)
4950 d->func (channel, d->data, 0);
4951 }
4952
4851 /* Really FIRST_PROC_DESC should be 0 on Unix, 4953 /* Really FIRST_PROC_DESC should be 0 on Unix,
4852 but this is safer in the short run. */ 4954 but this is safer in the short run. */
4853 for (channel = 0; channel <= max_process_desc; channel++) 4955 for (channel = 0; channel <= max_process_desc; channel++)
4854 { 4956 {
4855 if (FD_ISSET (channel, &Available) 4957 if (FD_ISSET (channel, &Available)
4856 && FD_ISSET (channel, &non_keyboard_wait_mask)) 4958 && FD_ISSET (channel, &non_keyboard_wait_mask)
4959 && !FD_ISSET (channel, &non_process_wait_mask))
4857 { 4960 {
4858 int nread; 4961 int nread;
4859 4962
@@ -4958,7 +5061,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4958 } 5061 }
4959 } 5062 }
4960#ifdef NON_BLOCKING_CONNECT 5063#ifdef NON_BLOCKING_CONNECT
4961 if (check_connect && FD_ISSET (channel, &Connecting) 5064 if (FD_ISSET (channel, &Writeok)
4962 && FD_ISSET (channel, &connect_wait_mask)) 5065 && FD_ISSET (channel, &connect_wait_mask))
4963 { 5066 {
4964 struct Lisp_Process *p; 5067 struct Lisp_Process *p;
@@ -5073,7 +5176,7 @@ read_process_output (Lisp_Object proc, register int channel)
5073 char *chars; 5176 char *chars;
5074 register Lisp_Object outstream; 5177 register Lisp_Object outstream;
5075 register struct Lisp_Process *p = XPROCESS (proc); 5178 register struct Lisp_Process *p = XPROCESS (proc);
5076 register int opoint; 5179 register EMACS_INT opoint;
5077 struct coding_system *coding = proc_decode_coding_system[channel]; 5180 struct coding_system *coding = proc_decode_coding_system[channel];
5078 int carryover = p->decoding_carryover; 5181 int carryover = p->decoding_carryover;
5079 int readmax = 4096; 5182 int readmax = 4096;
@@ -5097,7 +5200,13 @@ read_process_output (Lisp_Object proc, register int channel)
5097#endif 5200#endif
5098 if (proc_buffered_char[channel] < 0) 5201 if (proc_buffered_char[channel] < 0)
5099 { 5202 {
5100 nbytes = emacs_read (channel, chars + carryover, readmax); 5203#ifdef HAVE_GNUTLS
5204 if (NETCONN_P(proc) && GNUTLS_PROCESS_USABLE (proc))
5205 nbytes = emacs_gnutls_read (channel, XPROCESS (proc)->gnutls_state,
5206 chars + carryover, readmax);
5207 else
5208#endif
5209 nbytes = emacs_read (channel, chars + carryover, readmax);
5101#ifdef ADAPTIVE_READ_BUFFERING 5210#ifdef ADAPTIVE_READ_BUFFERING
5102 if (nbytes > 0 && p->adaptive_read_buffering) 5211 if (nbytes > 0 && p->adaptive_read_buffering)
5103 { 5212 {
@@ -5130,7 +5239,13 @@ read_process_output (Lisp_Object proc, register int channel)
5130 { 5239 {
5131 chars[carryover] = proc_buffered_char[channel]; 5240 chars[carryover] = proc_buffered_char[channel];
5132 proc_buffered_char[channel] = -1; 5241 proc_buffered_char[channel] = -1;
5133 nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1); 5242#ifdef HAVE_GNUTLS
5243 if (NETCONN_P(proc) && GNUTLS_PROCESS_USABLE (proc))
5244 nbytes = emacs_gnutls_read (channel, XPROCESS (proc)->gnutls_state,
5245 chars + carryover + 1, readmax - 1);
5246 else
5247#endif
5248 nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
5134 if (nbytes < 0) 5249 if (nbytes < 0)
5135 nbytes = 1; 5250 nbytes = 1;
5136 else 5251 else
@@ -5263,10 +5378,10 @@ read_process_output (Lisp_Object proc, register int channel)
5263 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) 5378 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
5264 { 5379 {
5265 Lisp_Object old_read_only; 5380 Lisp_Object old_read_only;
5266 int old_begv, old_zv; 5381 EMACS_INT old_begv, old_zv;
5267 int old_begv_byte, old_zv_byte; 5382 EMACS_INT old_begv_byte, old_zv_byte;
5268 int before, before_byte; 5383 EMACS_INT before, before_byte;
5269 int opoint_byte; 5384 EMACS_INT opoint_byte;
5270 Lisp_Object text; 5385 Lisp_Object text;
5271 struct buffer *b; 5386 struct buffer *b;
5272 5387
@@ -5403,11 +5518,11 @@ send_process_trap (int ignore)
5403 5518
5404static void 5519static void
5405send_process (volatile Lisp_Object proc, const unsigned char *volatile buf, 5520send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5406 volatile int len, volatile Lisp_Object object) 5521 volatile EMACS_INT len, volatile Lisp_Object object)
5407{ 5522{
5408 /* Use volatile to protect variables from being clobbered by longjmp. */ 5523 /* Use volatile to protect variables from being clobbered by longjmp. */
5409 struct Lisp_Process *p = XPROCESS (proc); 5524 struct Lisp_Process *p = XPROCESS (proc);
5410 int rv; 5525 EMACS_INT rv;
5411 struct coding_system *coding; 5526 struct coding_system *coding;
5412 struct gcpro gcpro1; 5527 struct gcpro gcpro1;
5413 SIGTYPE (*volatile old_sigpipe) (int); 5528 SIGTYPE (*volatile old_sigpipe) (int);
@@ -5464,8 +5579,8 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5464 coding->dst_object = Qt; 5579 coding->dst_object = Qt;
5465 if (BUFFERP (object)) 5580 if (BUFFERP (object))
5466 { 5581 {
5467 int from_byte, from, to; 5582 EMACS_INT from_byte, from, to;
5468 int save_pt, save_pt_byte; 5583 EMACS_INT save_pt, save_pt_byte;
5469 struct buffer *cur = current_buffer; 5584 struct buffer *cur = current_buffer;
5470 5585
5471 set_buffer_internal (XBUFFER (object)); 5586 set_buffer_internal (XBUFFER (object));
@@ -5517,7 +5632,7 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5517 process_sent_to = proc; 5632 process_sent_to = proc;
5518 while (len > 0) 5633 while (len > 0)
5519 { 5634 {
5520 int this = len; 5635 EMACS_INT this = len;
5521 5636
5522 /* Send this batch, using one or more write calls. */ 5637 /* Send this batch, using one or more write calls. */
5523 while (this > 0) 5638 while (this > 0)
@@ -5540,7 +5655,14 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5540 else 5655 else
5541#endif 5656#endif
5542 { 5657 {
5543 rv = emacs_write (outfd, (char *) buf, this); 5658#ifdef HAVE_GNUTLS
5659 if (NETCONN_P(proc) && GNUTLS_PROCESS_USABLE (proc))
5660 rv = emacs_gnutls_write (outfd,
5661 XPROCESS (proc)->gnutls_state,
5662 (char *) buf, this);
5663 else
5664#endif
5665 rv = emacs_write (outfd, (char *) buf, this);
5544#ifdef ADAPTIVE_READ_BUFFERING 5666#ifdef ADAPTIVE_READ_BUFFERING
5545 if (p->read_output_delay > 0 5667 if (p->read_output_delay > 0
5546 && p->adaptive_read_buffering == 1) 5668 && p->adaptive_read_buffering == 1)
@@ -5651,7 +5773,7 @@ Output from processes can arrive in between bunches. */)
5651 (Lisp_Object process, Lisp_Object start, Lisp_Object end) 5773 (Lisp_Object process, Lisp_Object start, Lisp_Object end)
5652{ 5774{
5653 Lisp_Object proc; 5775 Lisp_Object proc;
5654 int start1, end1; 5776 EMACS_INT start1, end1;
5655 5777
5656 proc = get_process (process); 5778 proc = get_process (process);
5657 validate_region (&start, &end); 5779 validate_region (&start, &end);
@@ -6592,8 +6714,8 @@ status_notify (struct Lisp_Process *deleting_process)
6592 { 6714 {
6593 Lisp_Object tem; 6715 Lisp_Object tem;
6594 struct buffer *old = current_buffer; 6716 struct buffer *old = current_buffer;
6595 int opoint, opoint_byte; 6717 EMACS_INT opoint, opoint_byte;
6596 int before, before_byte; 6718 EMACS_INT before, before_byte;
6597 6719
6598 /* Avoid error if buffer is deleted 6720 /* Avoid error if buffer is deleted
6599 (probably that's why the process is dead, too) */ 6721 (probably that's why the process is dead, too) */
@@ -6711,35 +6833,16 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6711 6833
6712 6834
6713 6835
6714static int add_gpm_wait_descriptor_called_flag;
6715
6716void 6836void
6717add_gpm_wait_descriptor (int desc) 6837add_gpm_wait_descriptor (int desc)
6718{ 6838{
6719 if (! add_gpm_wait_descriptor_called_flag) 6839 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} 6840}
6727 6841
6728void 6842void
6729delete_gpm_wait_descriptor (int desc) 6843delete_gpm_wait_descriptor (int desc)
6730{ 6844{
6731 int fd; 6845 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} 6846}
6744 6847
6745/* Return nonzero if *MASK has a bit set 6848/* Return nonzero if *MASK has a bit set
@@ -6750,7 +6853,7 @@ keyboard_bit_set (fd_set *mask)
6750{ 6853{
6751 int fd; 6854 int fd;
6752 6855
6753 for (fd = 0; fd <= max_keyboard_desc; fd++) 6856 for (fd = 0; fd <= max_input_desc; fd++)
6754 if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask) 6857 if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask)
6755 && !FD_ISSET (fd, &non_keyboard_wait_mask)) 6858 && !FD_ISSET (fd, &non_keyboard_wait_mask))
6756 return 1; 6859 return 1;
@@ -6989,11 +7092,11 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
6989void 7092void
6990add_keyboard_wait_descriptor (int desc) 7093add_keyboard_wait_descriptor (int desc)
6991{ 7094{
6992#ifdef subprocesses 7095#ifdef subprocesses /* actually means "not MSDOS" */
6993 FD_SET (desc, &input_wait_mask); 7096 FD_SET (desc, &input_wait_mask);
6994 FD_SET (desc, &non_process_wait_mask); 7097 FD_SET (desc, &non_process_wait_mask);
6995 if (desc > max_keyboard_desc) 7098 if (desc > max_input_desc)
6996 max_keyboard_desc = desc; 7099 max_input_desc = desc;
6997#endif 7100#endif
6998} 7101}
6999 7102
@@ -7004,18 +7107,16 @@ delete_keyboard_wait_descriptor (int desc)
7004{ 7107{
7005#ifdef subprocesses 7108#ifdef subprocesses
7006 int fd; 7109 int fd;
7007 int lim = max_keyboard_desc; 7110 int lim = max_input_desc;
7008 7111
7009 FD_CLR (desc, &input_wait_mask); 7112 FD_CLR (desc, &input_wait_mask);
7010 FD_CLR (desc, &non_process_wait_mask); 7113 FD_CLR (desc, &non_process_wait_mask);
7011 7114
7012 if (desc == max_keyboard_desc) 7115 if (desc == max_input_desc)
7013 for (fd = 0; fd < lim; fd++) 7116 for (fd = 0; fd < lim; fd++)
7014 if (FD_ISSET (fd, &input_wait_mask) 7117 if (FD_ISSET (fd, &input_wait_mask) || FD_ISSET (fd, &write_mask))
7015 && !FD_ISSET (fd, &non_keyboard_wait_mask) 7118 max_input_desc = fd;
7016 && !FD_ISSET (fd, &gpm_wait_mask)) 7119#endif
7017 max_keyboard_desc = fd;
7018#endif /* subprocesses */
7019} 7120}
7020 7121
7021/* Setup coding systems of PROCESS. */ 7122/* Setup coding systems of PROCESS. */
@@ -7272,7 +7373,9 @@ init_process (void)
7272 FD_ZERO (&input_wait_mask); 7373 FD_ZERO (&input_wait_mask);
7273 FD_ZERO (&non_keyboard_wait_mask); 7374 FD_ZERO (&non_keyboard_wait_mask);
7274 FD_ZERO (&non_process_wait_mask); 7375 FD_ZERO (&non_process_wait_mask);
7376 FD_ZERO (&write_mask);
7275 max_process_desc = 0; 7377 max_process_desc = 0;
7378 memset (fd_callback_info, 0, sizeof (fd_callback_info));
7276 7379
7277#ifdef NON_BLOCKING_CONNECT 7380#ifdef NON_BLOCKING_CONNECT
7278 FD_ZERO (&connect_wait_mask); 7381 FD_ZERO (&connect_wait_mask);
diff --git a/src/process.h b/src/process.h
index 35b01aba6a4..d6e842cfbbc 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,13 @@ 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 x509_cred;
137 gnutls_anon_client_credentials_t anon_cred;
138#endif
124}; 139};
125 140
126/* Every field in the preceding structure except for the first two 141/* Every field in the preceding structure except for the first two
@@ -177,5 +192,12 @@ extern void hold_keyboard_input (void);
177extern void unhold_keyboard_input (void); 192extern void unhold_keyboard_input (void);
178extern int kbd_on_hold_p (void); 193extern int kbd_on_hold_p (void);
179 194
195typedef void (*fd_callback)(int fd, void *data, int for_read);
196
197extern void add_read_fd (int fd, fd_callback func, void *data);
198extern void delete_read_fd (int fd);
199extern void add_write_fd (int fd, fd_callback func, void *data);
200extern void delete_write_fd (int fd);
201
180/* arch-tag: dffedfc4-d7bc-4b58-a26f-c16155449c72 202/* arch-tag: dffedfc4-d7bc-4b58-a26f-c16155449c72
181 (do not change this comment) */ 203 (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/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 4c4ae5e048b..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>
@@ -2618,9 +2614,10 @@ term_clear_mouse_face (void)
2618 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.
2619 - taken from msdos.c */ 2615 - taken from msdos.c */
2620static int 2616static int
2621fast_find_position (struct window *w, int pos, int *hpos, int *vpos) 2617fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos)
2622{ 2618{
2623 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;
2624 int yb = window_text_bottom_y (w); 2621 int yb = window_text_bottom_y (w);
2625 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;
2626 2623
@@ -2658,7 +2655,7 @@ fast_find_position (struct window *w, int pos, int *hpos, int *vpos)
2658 for (i = 0; i < row->used[TEXT_AREA]; i++) 2655 for (i = 0; i < row->used[TEXT_AREA]; i++)
2659 { 2656 {
2660 struct glyph *glyph = row->glyphs[TEXT_AREA] + i; 2657 struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
2661 int charpos; 2658 EMACS_INT charpos;
2662 2659
2663 charpos = glyph->charpos; 2660 charpos = glyph->charpos;
2664 if (charpos == pos) 2661 if (charpos == pos)
@@ -2719,7 +2716,8 @@ term_mouse_highlight (struct frame *f, int x, int y)
2719 && XFASTINT (w->last_modified) == BUF_MODIFF (b) 2716 && XFASTINT (w->last_modified) == BUF_MODIFF (b)
2720 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) 2717 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
2721 { 2718 {
2722 int pos, i, nrows = w->current_matrix->nrows; 2719 int i, nrows = w->current_matrix->nrows;
2720 EMACS_INT pos;
2723 struct glyph_row *row; 2721 struct glyph_row *row;
2724 struct glyph *glyph; 2722 struct glyph *glyph;
2725 2723
@@ -2763,7 +2761,8 @@ term_mouse_highlight (struct frame *f, int x, int y)
2763 /* Check for mouse-face. */ 2761 /* Check for mouse-face. */
2764 { 2762 {
2765 Lisp_Object mouse_face, overlay, position, *overlay_vec; 2763 Lisp_Object mouse_face, overlay, position, *overlay_vec;
2766 int noverlays, obegv, ozv; 2764 int noverlays;
2765 EMACS_INT obegv, ozv;
2767 struct buffer *obuf; 2766 struct buffer *obuf;
2768 2767
2769 /* 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. */
@@ -3404,6 +3403,15 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3404 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 3403 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
3405 Wcm_clear (tty); 3404 Wcm_clear (tty);
3406 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
3407#ifndef DOS_NT 3415#ifndef DOS_NT
3408 set_tty_hooks (terminal); 3416 set_tty_hooks (terminal);
3409 3417
@@ -3457,78 +3465,6 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3457 3465
3458 add_keyboard_wait_descriptor (fileno (tty->input)); 3466 add_keyboard_wait_descriptor (fileno (tty->input));
3459 3467
3460#endif /* !DOS_NT */
3461
3462 encode_terminal_src_size = 0;
3463 encode_terminal_dst_size = 0;
3464
3465#ifdef HAVE_GPM
3466 terminal->mouse_position_hook = term_mouse_position;
3467 mouse_face_window = Qnil;
3468#endif
3469
3470#ifdef DOS_NT
3471#ifdef WINDOWSNT
3472 initialize_w32_display (terminal);
3473#else /* MSDOS */
3474 if (strcmp (terminal_type, "internal") == 0)
3475 terminal->type = output_msdos_raw;
3476 initialize_msdos_display (terminal);
3477#endif /* MSDOS */
3478 tty->output = stdout;
3479 tty->input = stdin;
3480 /* The following two are inaccessible from w32console.c. */
3481 terminal->delete_frame_hook = &tty_free_frame_resources;
3482 terminal->delete_terminal_hook = &delete_tty;
3483
3484 tty->name = xstrdup (name);
3485 terminal->name = xstrdup (name);
3486 tty->type = xstrdup (terminal_type);
3487
3488 add_keyboard_wait_descriptor (0);
3489
3490 Wcm_clear (tty);
3491
3492#ifdef WINDOWSNT
3493 {
3494 struct frame *f = XFRAME (selected_frame);
3495
3496 FrameRows (tty) = FRAME_LINES (f);
3497 FrameCols (tty) = FRAME_COLS (f);
3498 tty->specified_window = FRAME_LINES (f);
3499
3500 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3501 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
3502 }
3503#else /* MSDOS */
3504 {
3505 int height, width;
3506 get_tty_size (fileno (tty->input), &width, &height);
3507 FrameCols (tty) = width;
3508 FrameRows (tty) = height;
3509 }
3510#endif /* MSDOS */
3511 tty->delete_in_insert_mode = 1;
3512
3513 UseTabs (tty) = 0;
3514 terminal->scroll_region_ok = 0;
3515
3516 /* Seems to insert lines when it's not supposed to, messing up the
3517 display. In doing a trace, it didn't seem to be called much, so I
3518 don't think we're losing anything by turning it off. */
3519 terminal->line_ins_del_ok = 0;
3520#ifdef WINDOWSNT
3521 terminal->char_ins_del_ok = 1;
3522 baud_rate = 19200;
3523#else /* MSDOS */
3524 terminal->char_ins_del_ok = 0;
3525 init_baud_rate (fileno (tty->input));
3526#endif /* MSDOS */
3527
3528 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
3529
3530#else /* not DOS_NT */
3531
3532 Wcm_clear (tty); 3468 Wcm_clear (tty);
3533 3469
3534 tty->termcap_term_buffer = (char *) xmalloc (buffer_size); 3470 tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
@@ -3680,7 +3616,64 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3680 tty->TF_underscore = tgetflag ("ul"); 3616 tty->TF_underscore = tgetflag ("ul");
3681 tty->TF_teleray = tgetflag ("xt"); 3617 tty->TF_teleray = tgetflag ("xt");
3682 3618
3683#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
3684 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 3677 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
3685 init_kboard (terminal->kboard); 3678 init_kboard (terminal->kboard);
3686 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 e9d67870078..ed13c3541cc 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1925,7 +1925,25 @@ get_emacs_configuration (void)
1925char * 1925char *
1926get_emacs_configuration_options (void) 1926get_emacs_configuration_options (void)
1927{ 1927{
1928 static char options_buffer[256]; 1928 static char *options_buffer;
1929 char cv[32]; /* Enough for COMPILER_VERSION. */
1930 char *options[] = {
1931 cv, /* To be filled later. */
1932#ifdef EMACSDEBUG
1933 " --no-opt",
1934#endif
1935 /* configure.bat already sets USER_CFLAGS and USER_LDFLAGS
1936 with a starting space to save work here. */
1937#ifdef USER_CFLAGS
1938 " --cflags", USER_CFLAGS,
1939#endif
1940#ifdef USER_LDFLAGS
1941 " --ldflags", USER_LDFLAGS,
1942#endif
1943 NULL
1944 };
1945 size_t size = 0;
1946 int i;
1929 1947
1930/* Work out the effective configure options for this build. */ 1948/* Work out the effective configure options for this build. */
1931#ifdef _MSC_VER 1949#ifdef _MSC_VER
@@ -1938,18 +1956,19 @@ get_emacs_configuration_options (void)
1938#endif 1956#endif
1939#endif 1957#endif
1940 1958
1941 sprintf (options_buffer, COMPILER_VERSION); 1959 if (_snprintf (cv, sizeof (cv) - 1, COMPILER_VERSION) < 0)
1942#ifdef EMACSDEBUG 1960 return "Error: not enough space for compiler version";
1943 strcat (options_buffer, " --no-opt"); 1961 cv[sizeof (cv) - 1] = '\0';
1944#endif 1962
1945#ifdef USER_CFLAGS 1963 for (i = 0; options[i]; i++)
1946 strcat (options_buffer, " --cflags"); 1964 size += strlen (options[i]);
1947 strcat (options_buffer, USER_CFLAGS); 1965
1948#endif 1966 options_buffer = xmalloc (size + 1);
1949#ifdef USER_LDFLAGS 1967 options_buffer[0] = '\0';
1950 strcat (options_buffer, " --ldflags"); 1968
1951 strcat (options_buffer, USER_LDFLAGS); 1969 for (i = 0; options[i]; i++)
1952#endif 1970 strcat (options_buffer, options[i]);
1971
1953 return options_buffer; 1972 return options_buffer;
1954} 1973}
1955 1974
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/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 e067958490c..809a5d24ef2 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
@@ -1052,8 +1052,8 @@ static int init_to_row_end (struct it *, struct window *,
1052static void back_to_previous_line_start (struct it *); 1052static void back_to_previous_line_start (struct it *);
1053static int forward_to_next_line_start (struct it *, int *); 1053static int forward_to_next_line_start (struct it *, int *);
1054static struct text_pos string_pos_nchars_ahead (struct text_pos, 1054static struct text_pos string_pos_nchars_ahead (struct text_pos,
1055 Lisp_Object, int); 1055 Lisp_Object, EMACS_INT);
1056static struct text_pos string_pos (int, Lisp_Object); 1056static struct text_pos string_pos (EMACS_INT, Lisp_Object);
1057static struct text_pos c_string_pos (int, const unsigned char *, int); 1057static struct text_pos c_string_pos (int, const unsigned char *, int);
1058static int number_of_chars (const unsigned char *, int); 1058static int number_of_chars (const unsigned char *, int);
1059static void compute_stop_pos (struct it *); 1059static void compute_stop_pos (struct it *);
@@ -1522,13 +1522,13 @@ string_char_and_length (const unsigned char *str, int *len)
1522 in STRING, return the position NCHARS ahead (NCHARS >= 0). */ 1522 in STRING, return the position NCHARS ahead (NCHARS >= 0). */
1523 1523
1524static struct text_pos 1524static struct text_pos
1525string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, int nchars) 1525string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, EMACS_INT nchars)
1526{ 1526{
1527 xassert (STRINGP (string) && nchars >= 0); 1527 xassert (STRINGP (string) && nchars >= 0);
1528 1528
1529 if (STRING_MULTIBYTE (string)) 1529 if (STRING_MULTIBYTE (string))
1530 { 1530 {
1531 int rest = SBYTES (string) - BYTEPOS (pos); 1531 EMACS_INT rest = SBYTES (string) - BYTEPOS (pos);
1532 const unsigned char *p = SDATA (string) + BYTEPOS (pos); 1532 const unsigned char *p = SDATA (string) + BYTEPOS (pos);
1533 int len; 1533 int len;
1534 1534
@@ -1552,7 +1552,7 @@ string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, int nchars)
1552 for character position CHARPOS in STRING. */ 1552 for character position CHARPOS in STRING. */
1553 1553
1554static INLINE struct text_pos 1554static INLINE struct text_pos
1555string_pos (int charpos, Lisp_Object string) 1555string_pos (EMACS_INT charpos, Lisp_Object string)
1556{ 1556{
1557 struct text_pos pos; 1557 struct text_pos pos;
1558 xassert (STRINGP (string)); 1558 xassert (STRINGP (string));
@@ -2653,7 +2653,7 @@ init_iterator (struct it *it, struct window *w,
2653 && WINDOWP (minibuf_selected_window) 2653 && WINDOWP (minibuf_selected_window)
2654 && w == XWINDOW (minibuf_selected_window)))) 2654 && w == XWINDOW (minibuf_selected_window))))
2655 { 2655 {
2656 int charpos = marker_position (current_buffer->mark); 2656 EMACS_INT charpos = marker_position (current_buffer->mark);
2657 it->region_beg_charpos = min (PT, charpos); 2657 it->region_beg_charpos = min (PT, charpos);
2658 it->region_end_charpos = max (PT, charpos); 2658 it->region_end_charpos = max (PT, charpos);
2659 } 2659 }
@@ -2899,7 +2899,7 @@ in_ellipses_for_invisible_text_p (struct display_pos *pos, struct window *w)
2899{ 2899{
2900 Lisp_Object prop, window; 2900 Lisp_Object prop, window;
2901 int ellipses_p = 0; 2901 int ellipses_p = 0;
2902 int charpos = CHARPOS (pos->pos); 2902 EMACS_INT charpos = CHARPOS (pos->pos);
2903 2903
2904 /* If POS specifies a position in a display vector, this might 2904 /* If POS specifies a position in a display vector, this might
2905 be for an ellipsis displayed for invisible text. We won't 2905 be for an ellipsis displayed for invisible text. We won't
@@ -3455,7 +3455,8 @@ handle_face_prop (struct it *it)
3455 } 3455 }
3456 else 3456 else
3457 { 3457 {
3458 int base_face_id, bufpos; 3458 int base_face_id;
3459 EMACS_INT bufpos;
3459 int i; 3460 int i;
3460 Lisp_Object from_overlay 3461 Lisp_Object from_overlay
3461 = (it->current.overlay_string_index >= 0 3462 = (it->current.overlay_string_index >= 0
@@ -3579,7 +3580,8 @@ face_before_or_after_it_pos (struct it *it, int before_p)
3579 3580
3580 if (STRINGP (it->string)) 3581 if (STRINGP (it->string))
3581 { 3582 {
3582 int bufpos, base_face_id; 3583 EMACS_INT bufpos;
3584 int base_face_id;
3583 3585
3584 /* No face change past the end of the string (for the case 3586 /* No face change past the end of the string (for the case
3585 we are padding with spaces). No face change before the 3587 we are padding with spaces). No face change before the
@@ -3622,7 +3624,7 @@ face_before_or_after_it_pos (struct it *it, int before_p)
3622 if (STRING_MULTIBYTE (it->string)) 3624 if (STRING_MULTIBYTE (it->string))
3623 { 3625 {
3624 const unsigned char *p = SDATA (it->string) + BYTEPOS (pos); 3626 const unsigned char *p = SDATA (it->string) + BYTEPOS (pos);
3625 int rest = SBYTES (it->string) - BYTEPOS (pos); 3627 EMACS_INT rest = SBYTES (it->string) - BYTEPOS (pos);
3626 int c, len; 3628 int c, len;
3627 struct face *face = FACE_FROM_ID (it->f, face_id); 3629 struct face *face = FACE_FROM_ID (it->f, face_id);
3628 3630
@@ -7411,7 +7413,7 @@ move_it_in_display_line (struct it *it,
7411 TO_CHARPOS. */ 7413 TO_CHARPOS. */
7412 7414
7413void 7415void
7414move_it_to (struct it *it, int to_charpos, int to_x, int to_y, int to_vpos, int op) 7416move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos, int op)
7415{ 7417{
7416 enum move_it_result skip, skip2 = MOVE_X_REACHED; 7418 enum move_it_result skip, skip2 = MOVE_X_REACHED;
7417 int line_height, line_start_x = 0, reached = 0; 7419 int line_height, line_start_x = 0, reached = 0;
@@ -7990,7 +7992,7 @@ message_log_maybe_newline (void)
7990 so the buffer M must NOT point to a Lisp string. */ 7992 so the buffer M must NOT point to a Lisp string. */
7991 7993
7992void 7994void
7993message_dolog (const char *m, int nbytes, int nlflag, int multibyte) 7995message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7994{ 7996{
7995 if (!NILP (Vmemory_full)) 7997 if (!NILP (Vmemory_full))
7996 return; 7998 return;
@@ -9189,7 +9191,7 @@ check_message_stack (void)
9189 time we display it---but don't redisplay it now. */ 9191 time we display it---but don't redisplay it now. */
9190 9192
9191void 9193void
9192truncate_echo_area (int nchars) 9194truncate_echo_area (EMACS_INT nchars)
9193{ 9195{
9194 if (nchars == 0) 9196 if (nchars == 0)
9195 echo_area_buffer[0] = Qnil; 9197 echo_area_buffer[0] = Qnil;
@@ -9628,7 +9630,7 @@ static int
9628store_mode_line_noprop (const unsigned char *str, int field_width, int precision) 9630store_mode_line_noprop (const unsigned char *str, int field_width, int precision)
9629{ 9631{
9630 int n = 0; 9632 int n = 0;
9631 int dummy, nbytes; 9633 EMACS_INT dummy, nbytes;
9632 9634
9633 /* Copy at most PRECISION chars from STR. */ 9635 /* Copy at most PRECISION chars from STR. */
9634 nbytes = strlen (str); 9636 nbytes = strlen (str);
@@ -11103,7 +11105,7 @@ int debug_dvpos, debug_dy;
11103 11105
11104/* Delta in characters and bytes for try_window_id. */ 11106/* Delta in characters and bytes for try_window_id. */
11105 11107
11106int debug_delta, debug_delta_bytes; 11108EMACS_INT debug_delta, debug_delta_bytes;
11107 11109
11108/* Values of window_end_pos and window_end_vpos at the end of 11110/* Values of window_end_pos and window_end_vpos at the end of
11109 try_window_id. */ 11111 try_window_id. */
@@ -11378,8 +11380,8 @@ overlay_arrow_at_row (struct it *it, struct glyph_row *row)
11378 position. BUF and PT are the current point buffer and position. */ 11380 position. BUF and PT are the current point buffer and position. */
11379 11381
11380int 11382int
11381check_point_in_composition (struct buffer *prev_buf, int prev_pt, 11383check_point_in_composition (struct buffer *prev_buf, EMACS_INT prev_pt,
11382 struct buffer *buf, int pt) 11384 struct buffer *buf, EMACS_INT pt)
11383{ 11385{
11384 EMACS_INT start, end; 11386 EMACS_INT start, end;
11385 Lisp_Object prop; 11387 Lisp_Object prop;
@@ -11432,7 +11434,7 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
11432 if (!b->clip_changed 11434 if (!b->clip_changed
11433 && BUFFERP (w->buffer) && !NILP (w->window_end_valid)) 11435 && BUFFERP (w->buffer) && !NILP (w->window_end_valid))
11434 { 11436 {
11435 int pt; 11437 EMACS_INT pt;
11436 11438
11437 if (w == XWINDOW (selected_window)) 11439 if (w == XWINDOW (selected_window))
11438 pt = BUF_PT (current_buffer); 11440 pt = BUF_PT (current_buffer);
@@ -11834,7 +11836,7 @@ redisplay_internal (int preserve_echo_area)
11834 { 11836 {
11835 struct glyph_row *row 11837 struct glyph_row *row
11836 = MATRIX_ROW (w->current_matrix, this_line_vpos + 1); 11838 = MATRIX_ROW (w->current_matrix, this_line_vpos + 1);
11837 int delta, delta_bytes; 11839 EMACS_INT delta, delta_bytes;
11838 11840
11839 /* We used to distinguish between two cases here, 11841 /* We used to distinguish between two cases here,
11840 conditioned by Z - CHARPOS (tlendpos) == ZV, for 11842 conditioned by Z - CHARPOS (tlendpos) == ZV, for
@@ -12463,7 +12465,8 @@ redisplay_window_1 (Lisp_Object window)
12463 12465
12464int 12466int
12465set_cursor_from_row (struct window *w, struct glyph_row *row, 12467set_cursor_from_row (struct window *w, struct glyph_row *row,
12466 struct glyph_matrix *matrix, int delta, int delta_bytes, 12468 struct glyph_matrix *matrix,
12469 EMACS_INT delta, EMACS_INT delta_bytes,
12467 int dy, int dvpos) 12470 int dy, int dvpos)
12468{ 12471{
12469 struct glyph *glyph = row->glyphs[TEXT_AREA]; 12472 struct glyph *glyph = row->glyphs[TEXT_AREA];
@@ -15056,7 +15059,7 @@ try_window_reusing_current_matrix (struct window *w)
15056 15059
15057static struct glyph_row *find_last_unchanged_at_beg_row (struct window *); 15060static struct glyph_row *find_last_unchanged_at_beg_row (struct window *);
15058static struct glyph_row *find_first_unchanged_at_end_row (struct window *, 15061static struct glyph_row *find_first_unchanged_at_end_row (struct window *,
15059 int *, int *); 15062 EMACS_INT *, EMACS_INT *);
15060static struct glyph_row * 15063static struct glyph_row *
15061find_last_row_displaying_text (struct glyph_matrix *, struct it *, 15064find_last_row_displaying_text (struct glyph_matrix *, struct it *,
15062 struct glyph_row *); 15065 struct glyph_row *);
@@ -15151,7 +15154,8 @@ find_last_unchanged_at_beg_row (struct window *w)
15151 changes. */ 15154 changes. */
15152 15155
15153static struct glyph_row * 15156static struct glyph_row *
15154find_first_unchanged_at_end_row (struct window *w, int *delta, int *delta_bytes) 15157find_first_unchanged_at_end_row (struct window *w,
15158 EMACS_INT *delta, EMACS_INT *delta_bytes)
15155{ 15159{
15156 struct glyph_row *row; 15160 struct glyph_row *row;
15157 struct glyph_row *row_found = NULL; 15161 struct glyph_row *row_found = NULL;
@@ -15382,13 +15386,14 @@ try_window_id (struct window *w)
15382 struct glyph_row *bottom_row; 15386 struct glyph_row *bottom_row;
15383 int bottom_vpos; 15387 int bottom_vpos;
15384 struct it it; 15388 struct it it;
15385 int delta = 0, delta_bytes = 0, stop_pos, dvpos, dy; 15389 EMACS_INT delta = 0, delta_bytes = 0, stop_pos;
15390 int dvpos, dy;
15386 struct text_pos start_pos; 15391 struct text_pos start_pos;
15387 struct run run; 15392 struct run run;
15388 int first_unchanged_at_end_vpos = 0; 15393 int first_unchanged_at_end_vpos = 0;
15389 struct glyph_row *last_text_row, *last_text_row_at_end; 15394 struct glyph_row *last_text_row, *last_text_row_at_end;
15390 struct text_pos start; 15395 struct text_pos start;
15391 int first_changed_charpos, last_changed_charpos; 15396 EMACS_INT first_changed_charpos, last_changed_charpos;
15392 15397
15393#if GLYPH_DEBUG 15398#if GLYPH_DEBUG
15394 if (inhibit_try_window_id) 15399 if (inhibit_try_window_id)
@@ -15515,7 +15520,7 @@ try_window_id (struct window *w)
15515 || (last_changed_charpos < CHARPOS (start) - 1 15520 || (last_changed_charpos < CHARPOS (start) - 1
15516 && FETCH_BYTE (BYTEPOS (start) - 1) == '\n'))) 15521 && FETCH_BYTE (BYTEPOS (start) - 1) == '\n')))
15517 { 15522 {
15518 int Z_old, delta, Z_BYTE_old, delta_bytes; 15523 EMACS_INT Z_old, delta, Z_BYTE_old, delta_bytes;
15519 struct glyph_row *r0; 15524 struct glyph_row *r0;
15520 15525
15521 /* Compute how many chars/bytes have been added to or removed 15526 /* Compute how many chars/bytes have been added to or removed
@@ -18377,7 +18382,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18377 { 18382 {
18378 /* A string: output it and check for %-constructs within it. */ 18383 /* A string: output it and check for %-constructs within it. */
18379 unsigned char c; 18384 unsigned char c;
18380 int offset = 0; 18385 EMACS_INT offset = 0;
18381 18386
18382 if (SCHARS (elt) > 0 18387 if (SCHARS (elt) > 0
18383 && (!NILP (props) || risky)) 18388 && (!NILP (props) || risky))
@@ -18474,7 +18479,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18474 && (mode_line_target != MODE_LINE_DISPLAY 18479 && (mode_line_target != MODE_LINE_DISPLAY
18475 || it->current_x < it->last_visible_x)) 18480 || it->current_x < it->last_visible_x))
18476 { 18481 {
18477 int last_offset = offset; 18482 EMACS_INT last_offset = offset;
18478 18483
18479 /* Advance to end of string or next format specifier. */ 18484 /* Advance to end of string or next format specifier. */
18480 while ((c = SREF (elt, offset++)) != '\0' && c != '%') 18485 while ((c = SREF (elt, offset++)) != '\0' && c != '%')
@@ -18482,7 +18487,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18482 18487
18483 if (offset - 1 != last_offset) 18488 if (offset - 1 != last_offset)
18484 { 18489 {
18485 int nchars, nbytes; 18490 EMACS_INT nchars, nbytes;
18486 18491
18487 /* Output to end of string or up to '%'. Field width 18492 /* Output to end of string or up to '%'. Field width
18488 is length of string. Don't output more than 18493 is length of string. Don't output more than
@@ -18501,11 +18506,11 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18501 break; 18506 break;
18502 case MODE_LINE_STRING: 18507 case MODE_LINE_STRING:
18503 { 18508 {
18504 int bytepos = last_offset; 18509 EMACS_INT bytepos = last_offset;
18505 int charpos = string_byte_to_char (elt, bytepos); 18510 EMACS_INT charpos = string_byte_to_char (elt, bytepos);
18506 int endpos = (precision <= 0 18511 EMACS_INT endpos = (precision <= 0
18507 ? string_byte_to_char (elt, offset) 18512 ? string_byte_to_char (elt, offset)
18508 : charpos + nchars); 18513 : charpos + nchars);
18509 18514
18510 n += store_mode_line_string (NULL, 18515 n += store_mode_line_string (NULL,
18511 Fsubstring (elt, make_number (charpos), 18516 Fsubstring (elt, make_number (charpos),
@@ -18515,8 +18520,8 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18515 break; 18520 break;
18516 case MODE_LINE_DISPLAY: 18521 case MODE_LINE_DISPLAY:
18517 { 18522 {
18518 int bytepos = last_offset; 18523 EMACS_INT bytepos = last_offset;
18519 int charpos = string_byte_to_char (elt, bytepos); 18524 EMACS_INT charpos = string_byte_to_char (elt, bytepos);
18520 18525
18521 if (precision <= 0) 18526 if (precision <= 0)
18522 nchars = string_byte_to_char (elt, offset) - charpos; 18527 nchars = string_byte_to_char (elt, offset) - charpos;
@@ -18529,7 +18534,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18529 } 18534 }
18530 else /* c == '%' */ 18535 else /* c == '%' */
18531 { 18536 {
18532 int percent_position = offset; 18537 EMACS_INT percent_position = offset;
18533 18538
18534 /* Get the specified minimum width. Zero means 18539 /* Get the specified minimum width. Zero means
18535 don't pad. */ 18540 don't pad. */
@@ -24167,7 +24172,8 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
24167 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 24172 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
24168 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 24173 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
24169 Lisp_Object pointer = Qnil; 24174 Lisp_Object pointer = Qnil;
24170 int charpos, dx, dy, width, height; 24175 int dx, dy, width, height;
24176 EMACS_INT charpos;
24171 Lisp_Object string, object = Qnil; 24177 Lisp_Object string, object = Qnil;
24172 Lisp_Object pos, help; 24178 Lisp_Object pos, help;
24173 24179
diff --git a/src/xml.c b/src/xml.c
index ddecabb5317..5829f1da538 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -30,41 +30,46 @@ 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
@@ -81,47 +86,47 @@ parse_string (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,
116 Sxml_parse_html_string_internal,
111 1, 2, 0, 117 1, 2, 0,
112 doc: /* Parse STRING as an HTML document and return the parse tree. 118 doc: /* Parse STRING as an HTML document and return the parse tree.
113If BASE-URL is non-nil, it will be used to expand relative URLs in 119If BASE-URL is non-nil, it is used to expand relative URLs. */)
114the HTML document. */)
115 (Lisp_Object string, Lisp_Object base_url) 120 (Lisp_Object string, Lisp_Object base_url)
116{ 121{
117 return parse_string (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,
126 Sxml_parse_string_internal,
121 1, 2, 0, 127 1, 2, 0,
122 doc: /* Parse STRING as an XML document and return the parse tree. 128 doc: /* Parse STRING as an XML document and return the parse tree.
123If BASE-URL is non-nil, it will be used to expand relative URLs in 129If BASE-URL is non-nil, it is used to expand relative URLs. */)
124the XML document. */)
125 (Lisp_Object string, Lisp_Object base_url) 130 (Lisp_Object string, Lisp_Object base_url)
126{ 131{
127 return parse_string (string, base_url, 0); 132 return parse_string (string, base_url, 0);
@@ -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