aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2011-09-21 10:41:20 -0700
committerPaul Eggert2011-09-21 10:41:20 -0700
commitd311d28c3f8a3c43e6ef33d68b852c5ea7f13239 (patch)
tree84b390c8bd472074294a31d51e790437f0a9a75d /src/coding.c
parent4768be09c9866add356a0a9b47ecd42346442b9f (diff)
downloademacs-d311d28c3f8a3c43e6ef33d68b852c5ea7f13239.tar.gz
emacs-d311d28c3f8a3c43e6ef33d68b852c5ea7f13239.zip
* alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp):
(allocate_vectorlike, buffer_memory_full, struct sdata, SDATA_SIZE) (string_bytes, check_sblock, allocate_string_data): (compact_small_strings, Fmake_bool_vector, make_string) (make_unibyte_string, make_multibyte_string) (make_string_from_bytes, make_specified_string) (allocate_vectorlike, Fmake_vector, find_string_data_in_pure) (make_pure_string, make_pure_c_string, make_pure_vector, Fpurecopy) (mark_vectorlike): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (allocate_pseudovector): Use int, not EMACS_INT, where int is wide enough. (inhibit_garbage_collection, Fgarbage_collect): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * bidi.c (bidi_mirror_char): Use EMACS_INT, not int, where int might not be wide enough. (bidi_cache_search, bidi_cache_find, bidi_init_it) (bidi_count_bytes, bidi_char_at_pos, bidi_fetch_char) (bidi_at_paragraph_end, bidi_find_paragraph_start) (bidi_paragraph_init, bidi_resolve_explicit, bidi_resolve_weak) (bidi_level_of_next_char, bidi_move_to_visually_next): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * buffer.c (copy_overlays, Fgenerate_new_buffer_name) (Fkill_buffer, Fset_buffer_major_mode) (advance_to_char_boundary, Fbuffer_swap_text) (Fset_buffer_multibyte, overlays_at, overlays_in) (overlay_touches_p, struct sortvec, record_overlay_string) (overlay_strings, recenter_overlay_lists) (adjust_overlays_for_insert, adjust_overlays_for_delete) (fix_start_end_in_overlays, fix_overlays_before, modify_overlay) (Fmove_overlay, Fnext_overlay_change, Fprevious_overlay_change) (Foverlay_recenter, last_overlay_modification_hooks_used) (report_overlay_modification, evaporate_overlays, enlarge_buffer_text): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (validate_region): Omit unnecessary test for b <= e, since that's guaranteed by the previous test. (adjust_overlays_for_delete): Avoid pos + length overflow. (Fmove_overlay, Fdelete_overlay, add_overlay_mod_hooklist) (report_overlay_modification): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Foverlays_at, Fnext_overlay_change, Fprevious_overlay_change): Omit pointer cast, which isn't needed anyway, and doesn't work after the EMACS_INT -> ptrdiff_t change. * buffer.h: Adjust decls to match defn changes elsewhere. (struct buffer_text, struct buffer): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. Use EMACS_INT, not int, where int might not be wide enough. * bytecode.c (exec_byte_code): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. Remove unnecessary memory-full test. Use EMACS_INT, not ptrdiff_t or int, where ptrdiff_t or int might not be wide enough. * callint.c (Fcall_interactively): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * callproc.c (call_process_kill, Fcall_process): Don't assume pid_t fits into an Emacs fixnum. (call_process_cleanup, Fcall_process, child_setup): Don't assume pid_t fits into int. (call_process_cleanup, Fcall_process, delete_temp_file) (Fcall_process_region): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Fcall_process): Simplify handling of volatile integers. Use int, not EMACS_INT, where int will do. * casefiddle.c (casify_object, casify_region, operate_on_word) (Fupcase_word, Fdowncase_word, Fcapitalize_word): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (casify_object): Avoid integer overflow when overallocating buffer. * casetab.c (set_identity, shuffle): Prefer int to unsigned when either works. * category.c (Fchar_category_set): Don't assume fixnum fits in int. * category.h (CATEGORYP): Don't assume arg is nonnegative. * ccl.c (GET_CCL_INT): Remove; no longer needed, since the integers are now checked earlier. All uses replaced with XINT. (ccl_driver): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. For CCL_MapSingle, check that content and value are in int range. (resolve_symbol_ccl_program): Check that vector header is in range. Always copy the vector, so that we can check its contents reliably now rather than having to recheck each instruction as it's being executed. Check that vector words fit in 'int'. (ccl_get_compiled_code, Fregister_ccl_program) (Fregister_code_conversion_map): Use ptrdiff_t, not int, for program indexes, to avoid needless 32-bit limit on 64-bit hosts. (Fccl_execute, Fccl_execute_on_string): Check that initial reg contents are in range. (Fccl_execute_on_string): Check that status is in range. * ccl.h (struct ccl_program.idx): Now ptrdiff_t, not int. * character.c (char_resolve_modifier_mask, Fchar_resolve_modifiers): Accept and return EMACS_INT, not int, because callers can pass values out of 'int' range. (c_string_width, strwidth, lisp_string_width, chars_in_text) (multibyte_chars_in_text, parse_str_as_multibyte) (str_as_multibyte, count_size_as_multibyte, str_to_multibyte) (str_as_unibyte, str_to_unibyte, string_count_byte8) (string_escape_byte8, Fget_byte): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Funibyte_string): Use CHECK_CHARACTER, not CHECK_NATNUM, to avoid mishandling large integers. * character.h: Adjust decls to match defn changes elsewhere. * charset.c (load_charset_map_from_file, find_charsets_in_text) (Ffind_charset_region): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (load_charset_map_from_file): Redo idx calculation to avoid overflow. (load_charset_map_from_vector, Fdefine_charset_internal): Don't assume fixnum fits in int or unsigned int. (load_charset_map_from_vector, Fmap_charset_chars): Remove now-unnecessary CHECK_NATNUMs. (Fdefine_charset_internal): Check ranges here, more carefully. * chartab.c (Fmake_char_table, Fset_char_table_range) (uniprop_get_decoder, uniprop_get_encoder): Don't assume fixnum fits in int. * cmds.c (move_point): New function, that does the gist of Fforward_char and Fbackward_char, but does so while checking for integer overflow more accurately. (Fforward_char, Fbackward_char, internal_self_insert): Use it. (Fforward_line, Fend_of_line, internal_self_insert) (internal_self_insert): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. Fix a FIXME, by checking for integer overflow when calculating target_clm and actual_clm. * coding.c (detect_coding_XXX, encode_coding_XXX, CODING_DECODE_CHAR) (ASSURE_DESTINATION, coding_alloc_by_realloc) (coding_alloc_by_making_gap, alloc_destination) (detect_coding_utf_8, encode_coding_utf_8, decode_coding_utf_16) (encode_coding_utf_16, detect_coding_emacs_mule) (decode_coding_emacs_mule, encode_coding_emacs_mule) (detect_coding_iso_2022, decode_coding_iso_2022) (encode_invocation_designation, encode_designation_at_bol) (encode_coding_iso_2022, detect_coding_sjis, detect_coding_big5) (decode_coding_sjis, decode_coding_big5, encode_coding_sjis) (encode_coding_big5, detect_coding_ccl, decode_coding_ccl) (encode_coding_ccl, encode_coding_raw_text) (detect_coding_charset, decode_coding_charset) (encode_coding_charset, detect_eol, decode_eol, produce_chars) (produce_composition, produce_charset, produce_annotation) (decode_coding, handle_composition_annotation) (handle_charset_annotation, consume_chars, decode_coding_gap) (decode_coding_object, encode_coding_object, detect_coding_system) (Ffind_coding_systems_region_internal, Fcheck_coding_systems_region) (code_convert_region, code_convert_string) (Fdefine_coding_system_internal): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (setup_iso_safe_charsets, consume_chars, Funencodable_char_position) (Fdefine_coding_system_internal): Don't assume fixnums fit in int. (decode_coding_gap, decode_coding_object, encode_coding_object) (Fread_coding_system, Fdetect_coding_region, Funencodable_char_position) (Fcheck_coding_systems_region): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Ffind_operation_coding_system): NATNUMP can eval its arg twice. (Fdefine_coding_system_internal): Check for charset-id overflow. * coding.h: Adjust decls to match defn changes elsewhere. (struct coding_system): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * composite.c (get_composition_id, find_composition) (run_composition_function, update_compositions) (compose_text, composition_gstring_put_cache) (composition_gstring_p, composition_gstring_width) (fill_gstring_header, fill_gstring_body, autocmp_chars) (composition_compute_stop_pos, composition_reseat_it) (composition_update_it, struct position_record) (find_automatic_composition, composition_adjust_point) (Fcomposition_get_gstring, Ffind_composition_internal): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (update_compositions): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * composite.h: Adjust decls to match defn changes elsewhere. (struct composition): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * data.c (let_shadows_buffer_binding_p, let_shadows_global_binding_p): Do not attempt to compute the address of the object just before a buffer; this is not portable. (Faref, Faset): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Faset): Use int, not EMACS_INT, where int is wide enough. (Fstring_to_number): Don't assume fixnums fit in int. (Frem): Don't assume arg is nonnegative. * dbusbind.c (xd_append_arg): Check for integers out of range. (Fdbus_call_method): Don't overflow the timeout int. * dired.c (directory_files_internal, file_name_completion, scmp) (file_name_completion_stat): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (file_name_completion): Don't overflow matchcount. (file_name_completion_stat): Use SAFE_ALLOCA, not alloca. * dispextern.h: Adjust decls to match defn changes elsewhere. (struct text_pos, struct glyph, struct bidi_saved_info) (struct bidi_string_data, struct bidi_it, struct composition_it) (struct it): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (struct display_pos, struct composition_it, struct it): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * dispnew.c (increment_matrix_positions) (increment_row_positions, mode_line_string) (marginal_area_string): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (change_frame_size_1, Fredisplay): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (duration_to_sec_usec): New function, to check for overflow better. (Fsleep_for, sit_for): Use it. * doc.c (get_doc_string, store_function_docstring): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (get_doc_string, Fsnarf_documentation): Use int, not EMACS_INT, where int is wide enough. (get_doc_string): Use SAFE_ALLOCA, not alloca. Check for overflow when converting EMACS_INT to off_t. * doprnt.c (doprnt): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * editfns.c (init_editfns, Fuser_uid, Fuser_real_uid): Don't assume uid_t fits into fixnum. (buildmark, Fgoto_char, overlays_around, find_field, Fdelete_field) (Ffield_string, Ffield_string_no_properties, Ffield_beginning) (Ffield_end, Fconstrain_to_field, Fline_beginning_position) (Fline_end_position, Fprevious_char, Fchar_after, Fchar_before) (general_insert_function) (Finsert_char, make_buffer_string, make_buffer_string_both) (update_buffer_properties, Fbuffer_substring) (Fbuffer_substring_no_properties, Fcompare_buffer_substrings) (Fsubst_char_in_region, check_translation) (Ftranslate_region_internal, save_restriction_restore, Fformat) (transpose_markers, Ftranspose_regions): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (clip_to_bounds): Move to lisp.h as an inline function). (Fconstrain_to_field): Don't assume integers are nonnegative. (Fline_beginning_position, Fsave_excursion, Fsave_current_buffer): (Fsubst_char_in_region, Fsave_restriction): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Femacs_pid): Don't assume pid_t fits into fixnum. (lo_time): Use int, not EMACS_INT, when int suffices. (lisp_time_argument): Check for usec out of range. (Fencode_time): Don't assume fixnum fits in int. * emacs.c (gdb_valbits, gdb_gctypebits): Now int, not EMACS_INT. (gdb_data_seg_bits): Now uintptr_t, not EMACS_INT. (PVEC_FLAG, gdb_array_mark_flag): Now ptrdiff_t, not EMACS_INT. (init_cmdargs, Fdump_emacs): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Fkill_emacs): Don't assume fixnum fits in int; instead, take just the bottom (typically) 32 bits of the fixnum. * eval.c (specpdl_size, call_debugger): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (when_entered_debugger, Fbacktrace_debug): Don't assume fixnum can fit in int. (Fdefvaralias, Fdefvar): Do not attempt to compute the address of the object just before a buffer; this is not portable. (FletX, Flet, Funwind_protect, do_autoload, Feval, funcall_lambda) (grow_specpdl, unbind_to): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Fapply, apply_lambda): Don't assume ptrdiff_t can hold fixnum. (grow_specpdl): Simplify allocation by using xpalloc. * fileio.c (Ffind_file_name_handler, Fcopy_file, Frename_file) (Finsert_file_contents, Fwrite_region, Fdo_auto_save): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Ffind_file_name_handler, non_regular_inserted, Finsert_file_contents) (a_write, e_write): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fcopy_file, non_regular_nbytes, read_non_regular) (Finsert_file_contents): Use int, not EMACS_INT, where int is wide enough. (READ_BUF_SIZE): Verify that it fits in int. (Finsert_file_contents): Check that counts are in proper range, rather than assuming fixnums fit into ptrdiff_t etc. Don't assume fixnums fit into int. (Fdo_auto_save, Fset_buffer_auto_saved) (Fclear_buffer_auto_save_failure): Don't assume time_t is signed, or that it fits in int. * fns.c (Fcompare_strings, Fstring_lessp, struct textprop_rec) (concat, string_char_byte_cache_charpos, string_char_byte_cache_bytepos) (string_char_to_byte, string_byte_to_char) (string_make_multibyte, string_to_multibyte) (string_make_unibyte, Fstring_as_unibyte, Fstring_as_multibyte) (Fstring_to_unibyte, Fsubstring, Fsubstring_no_properties) (substring_both, Fdelete, internal_equal, Ffillarray) (Fclear_string, mapcar1) (Fbase64_encode_region, Fbase64_encode_string, base64_encode_1) (Fbase64_decode_region, Fbase64_decode_string, base64_decode_1) (larger_vector, make_hash_table, maybe_resize_hash_table) (hash_lookup, hash_remove_from_table, hash_clear, sweep_weak_table) (Fmaphash, secure_hash): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (concat): Check for string index and length overflow. (Fmapconcat): Don't assume fixnums fit into ptrdiff_t. (Frequire): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (larger_vector): New API (vec, incr_min, size_max) replaces old one (vec, new_size, init). This catches size overflow. INIT was removed because it was always Qnil. All callers changed. (INDEX_SIZE_BOUND): New macro, which calculates more precisely the upper bound on a hash table index size. (make_hash_table, maybe_resize_hash_table): Use it. (secure_hash): Computer start_byte and end_byte only after they're known to be in ptrdiff_t range. * font.c (font_intern_prop, font_at, font_range, Ffont_shape_gstring) (Ffont_get_glyphs, Ffont_at): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (font_style_to_value, font_prop_validate_style, font_expand_wildcards) (Flist_fonts, Fopen_font): Don't assume fixnum can fit in int. (check_gstring): Don't assume index can fit in int. (font_match_p): Check that fixnum is a character, not a nonnegative fixnum, since the later code needs to stuff it into an int. (font_find_for_lface): Use SAFE_ALLOCA_LISP, not alloca. (font_fill_lglyph_metrics): Use unsigned, not EMACS_INT, to avoid conversion overflow issues. (Fopen_font): Check for integer out of range. (Ffont_get_glyphs): Don't assume index can fit in int. * font.h: Adjust decls to match defn changes elsewhere. * fontset.c (reorder_font_vector): Redo score calculation to avoid integer overflow. (num_auto_fontsets, fontset_from_font): Use ptrdiff_t, not printmax_t, where ptrdiff_t is wide enough. (Finternal_char_font): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * frame.c (Fset_mouse_position, Fset_mouse_pixel_position) (Fset_frame_height, Fset_frame_width, Fset_frame_size) (Fset_frame_position, x_set_frame_parameters) (x_set_line_spacing, x_set_border_width) (x_set_internal_border_width, x_set_alpha, x_figure_window_size): Check that fixnums are in proper range for system types. (frame_name_fnn_p, Fframe_parameter, Fmodify_frame_parameters): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fmodify_frame_parameters): Don't assume fixnum fits in int. Use SAFE_ALLOCA_LISP, not alloca. * frame.h (struct frame): Use intptr_t, not EMACS_INT, where intptr_t is wide enough. * fringe.c (lookup_fringe_bitmap, get_logical_fringe_bitmap) (Fdefine_fringe_bitmap): Don't assume fixnum fits in int. (Ffringe_bitmaps_at_pos): Don't assume index fits in int. Check for fixnum out of range. * ftfont.c (ftfont_list): Don't assume index fits in int. Check that fixnums are in proper range for system types. (ftfont_shape_by_flt): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. Remove no-longer-needed lint_assume. * gnutls.c (emacs_gnutls_write, emacs_gnutls_read): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fgnutls_error_fatalp, Fgnutls_error_string, Fgnutls_boot): Check that fixnums are in proper range for system types. * gnutls.h: Adjust decls to match defn changes elsewhere. * gtkutil.c (xg_dialog_run): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (update_frame_tool_bar): Check that fixnums are in proper range for system types. * image.c (parse_image_spec): Redo count calculation to avoid overflow. (lookup_image): Check that fixnums are in proper range for system types. * indent.c (last_known_column, last_known_column_point): (current_column_bol_cache): (skip_invisible, current_column, check_display_width): (check_display_width, scan_for_column, current_column_1) (Findent_to, Fcurrent_indentation, position_indentation) (indented_beyond_p, Fmove_to_column, compute_motion): (Fcompute_motion, Fvertical_motion): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (last_known_column_modified): Use EMACS_INT, not int. (check_display_width): (Fcompute_motion): Check that fixnums and floats are in proper range for system types. (compute_motion): Don't assume index or fixnum fits in int. (compute_motion, Fcompute_motion): Use int, not EMACS_INT, when it is wide enough. (vmotion): Omit local var start_hpos that is always 0; that way we don't need to worry about overflow in expressions involving it. * indent.h: Adjust decls to match defn changes elsewhere. (struct position): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. Use int, not EMACS_INT, where int is wide enough. Remove unused members ovstring_chars_done and tab_offset; all uses removed. * insdel.c (move_gap, move_gap_both, gap_left, gap_right) (adjust_markers_for_delete, adjust_markers_for_insert, adjust_point) (adjust_markers_for_replace, make_gap_larger, make_gap_smaller) (make_gap, copy_text, insert, insert_and_inherit) (insert_before_markers, insert_before_markers_and_inherit) (insert_1, count_combining_before, count_combining_after) (insert_1_both, insert_from_string) (insert_from_string_before_markers, insert_from_string_1) (insert_from_gap, insert_from_buffer, insert_from_buffer_1) (adjust_after_replace, adjust_after_insert, replace_range) (replace_range_2, del_range, del_range_1, del_range_byte) (del_range_both, del_range_2, modify_region) (prepare_to_modify_buffer, signal_before_change) (signal_after_change, Fcombine_after_change_execute): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * intervals.c (traverse_intervals, rotate_right, rotate_left) (balance_an_interval, split_interval_right, split_interval_left) (find_interval, next_interval, update_interval) (adjust_intervals_for_insertion, delete_node, delete_interval) (interval_deletion_adjustment, adjust_intervals_for_deletion) (static_offset_intervals, offset_intervals) (merge_interval_right, merge_interval_left, make_new_interval) (graft_intervals_into_buffer, temp_set_point_both) (temp_set_point, set_point, adjust_for_invis_intang) (set_point_both, move_if_not_intangible, get_property_and_range) (get_local_map, copy_intervals, copy_intervals_to_string) (compare_string_intervals, set_intervals_multibyte_1): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * intervals.h: Adjust decls to match defn changes elsewhere. (struct interval): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * keyboard.c (this_command_key_count, this_single_command_key_start) (before_command_key_count, before_command_echo_length, echo_now) (echo_length, recursive_edit_1, Frecursive_edit, Ftrack_mouse) (command_loop_1, safe_run_hooks, read_char, timer_check_2) (menu_item_eval_property, read_key_sequence, Fread_key_sequence) (Fread_key_sequence_vector, Fexecute_extended_command, Fsuspend_emacs): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (last_non_minibuf_size, last_point_position, echo_truncate) (command_loop_1, adjust_point_for_property, read_char, gen_help_event) (make_lispy_position, make_lispy_event, parse_modifiers_uncached) (parse_modifiers, modify_event_symbol, Fexecute_extended_command) (stuff_buffered_input): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (last_auto_save, command_loop_1, read_char): Use EMACS_INT, not int, to avoid integer overflow. (record_char): Avoid overflow in total_keys computation. (parse_modifiers_uncached): Redo index calculation to avoid overflow. * keyboard.h: Adjust decls to match defn changes elsewhere. * keymap.c (Fdefine_key, Fcurrent_active_maps, accessible_keymaps_1) (Fkey_description, Fdescribe_vector, Flookup_key): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (click_position): New function, to check that positions are in range. (Fcurrent_active_maps): (describe_command): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Faccessible_keymaps, Fkey_description): (preferred_sequence_p): Don't assume fixnum can fit into int. (Fkey_description): Use SAFE_ALLOCA_LISP, not alloca. Check for integer overflow in size calculations. (Ftext_char_description): Use CHECK_CHARACTER, not CHECK_NUMBER, to avoid mishandling large integers. * lisp.h: Adjust decls to match defn changes elsewhere. (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, struct Lisp_String) (struct vectorlike_header, struct Lisp_Subr, struct Lisp_Hash_Table) (struct Lisp_Marker): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (clip_to_bounds): Now an inline function, moved here from editfns.c. (XSETSUBR): Use size of 0 since the actual size doesn't matter, and using 0 avoids overflow. (GLYPH_CODE_P): Check for overflow in system types, subsuming the need for GLYPH_CODE_CHAR_VALID_P and doing proper checking ourselves. All callers changed. (GLYPH_CODE_CHAR, GLYPH_CODE_FACE): Assume the arg has valid form, since it always does. (TYPE_RANGED_INTEGERP): Avoid bug when checking against a wide unsigned integer system type. (CHECK_RANGED_INTEGER, CHECK_TYPE_RANGED_INTEGER): New macros. (struct catchtag, specpdl_size, SPECPDL_INDEX, USE_SAFE_ALLOCA): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (struct catchtag): Use EMACS_INT, not int, since it may be a fixnum. (duration_to_sec_usec): New decl. * lread.c (read_from_string_index, read_from_string_index_byte) (read_from_string_limit, readchar, unreadchar, openp) (read_internal_start, read1, oblookup): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fload, readevalloop, Feval_buffer, Feval_region): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (openp): Check for out-of-range argument to 'access'. (read1): Use int, not EMACS_INT, where int is wide enough. Don't assume fixnum fits into int. * macros.c (Fstart_kbd_macro): Use xpalloc to check for overflow in size calculation. (Fexecute_kbd_macro): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * marker.c (cached_charpos, cached_bytepos, CONSIDER) (byte_char_debug_check, buf_charpos_to_bytepos, verify_bytepos) (buf_bytepos_to_charpos, Fset_marker, set_marker_restricted) (set_marker_both, set_marker_restricted_both, marker_position) (marker_byte_position, Fbuffer_has_markers_at): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fset_marker, set_marker_restricted): Don't assume fixnum fits in int. * menu.c (ensure_menu_items): Renamed from grow_menu_items. It now merely ensures that the menu is large enough, without necessarily growing it, as this avoids some integer overflow issues. All callers changed. (keymap_panes, parse_single_submenu, Fx_popup_menu): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (parse_single_submenu, Fx_popup_menu): Don't assume fixnum fits in int. Use SAFE_ALLOCA_LISP, not alloca. (find_and_return_menu_selection): Avoid unnecessary casts of pointers to EMACS_INT. Check that fixnums are in proper range for system types. * minibuf.c (minibuf_prompt_width, string_to_object) (Fminibuffer_contents, Fminibuffer_contents_no_properties) (Fminibuffer_completion_contents, Ftry_completion, Fall_completions): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (get_minibuffer, read_minibuf_unwind): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (read_minibuf): Omit unnecessary arg BACKUP_N, which is always nil; this simplifies overflow checking. All callers changed. (read_minibuf, Fread_buffer, Ftry_completion, Fall_completions) (Ftest_completion): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * nsfns.m (check_ns_display_info): Don't assume fixnum fits in long. (x_set_menu_bar_lines, x_set_tool_bar_lines, Fx_create_frame): Check that fixnums are in proper range for system types. (Fx_create_frame, Fx_show_tip): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * nsfont.m (ns_findfonts, nsfont_list_family): Don't assume fixnum fits in long. * nsmenu.m (ns_update_menubar, ns_menu_show, ns_popup_dialog): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (ns_update_menubar): Use intptr_t, not EMACS_INT, when intptr_t is wide enough. * nsselect.m (ns_get_local_selection): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * print.c (print_buffer_size, print_buffer_pos, print_buffer_pos_byte) (PRINTDECLARE, PRINTPREPARE): (strout, print_string): (print, print_preprocess, print_check_string_charset_prop) (print_object): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (PRINTDECLARE): (temp_output_buffer_setup, Fprin1_to_string, print_object): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (PRINTPREPARE): Use int, not ptrdiff_t, where int is wide enough. (PRINTFINISH): Use SAFE_ALLOCA, not alloca. (printchar, strout): Use xpalloc to catch size calculation overflow. (Fexternal_debugging_output): Use CHECK_CHARACTER, not CHECK_NUMBER, to avoid mishandling large integers. (print_error_message): Use SAFE_ALLOCA, not alloca. (print_object): Use int, not EMACS_INT, where int is wide enough. * process.c (Fdelete_process): Don't assume pid fits into EMACS_INT. (Fset_process_window_size, Fformat_network_address) (get_lisp_to_sockaddr_size, set_socket_option, Fmake_network_process) (Fsignal_process, sigchld_handler): Check that fixnums are in proper range for system types. (Fformat_network_address, read_process_output, send_process) (Fprocess_send_region, status_notify): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fformat_network_address, Fmake_serial_process, Fmake_network_process) (wait_reading_process_output, read_process_output, exec_sentinel): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (conv_lisp_to_sockaddr): Don't assume fixnums fit into int. (Faccept_process_output): Use duration_to_sec_usec to do proper overflow checking on durations. * scroll.c (calculate_scrolling, calculate_direct_scrolling) (line_ins_del): Use int, not EMACS_INT, where int is wide enough. * search.c (looking_at_1, string_match_1): (fast_string_match, fast_c_string_match_ignore_case) (fast_string_match_ignore_case, fast_looking_at, scan_buffer) (scan_newline, find_before_next_newline, search_command) (trivial_regexp_p, search_buffer, simple_search, boyer_moore) (set_search_regs, wordify): (Freplace_match): (Fmatch_data): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (string_match_1, search_buffer, set_search_regs): (Fmatch_data): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (wordify): Check for overflow in size calculation. (Freplace_match): Avoid potential buffer overflow in search_regs.start. (Fset_match_data): Don't assume fixnum fits in ptrdiff_t. Check that fixnums are in proper range for system types. * sound.c (struct sound_device) (wav_play, au_play, vox_write, alsa_period_size, alsa_write): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fplay_sound_internal): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * syntax.c (ST_COMMENT_STYLE, ST_STRING_STYLE): In definitions, make it clearer that these values must be out of range for the respective integer ranges. This fixes a bug with ST_STRING_STYLE and non-ASCII characters. (struct lisp_parse_state, find_start_modiff) (Finternal_describe_syntax_value, scan_lists, scan_sexps_forward): (Fparse_partial_sexp): Don't assume fixnums can fit in int. (struct lisp_parse_state, find_start_pos, find_start_value) (find_start_value_byte, find_start_begv) (update_syntax_table, char_quoted, dec_bytepos) (find_defun_start, prev_char_comend_first, back_comment): (scan_words, skip_chars, skip_syntaxes, forw_comment, Fforward_comment) (scan_lists, Fbackward_prefix_chars, scan_sexps_forward): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Finternal_describe_syntax_value): Check that match_lisp is a character, not an integer, since the code stuffs it into int. (scan_words, scan_sexps_forward): Check that fixnums are in proper range for system types. (Fforward_word): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (scan_sexps_forward): Use CHARACTERP, not INTEGERP, since the value must fit into int. (Fparse_partial_sexp): Fix doc; element 8 is not ignored. * syntax.h: Adjust decls to match defn changes elsewhere. (struct gl_state_s): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * sysdep.c (wait_for_termination_1, wait_for_termination) (interruptible_wait_for_termination, mkdir): Don't assume pid_t fits in int; on 64-bit AIX pid_t is 64-bit. (emacs_read, emacs_write): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (system_process_attributes): Don't assume uid_t, gid_t, and double all fit in int or even EMACS_INT. * term.c (set_tty_color_mode): Check that fixnums are in proper range for system types. * termhooks.h (struct input_event): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * textprop.c (validate_interval_range, interval_of) (Fadd_text_properties, set_text_properties_1) (Fremove_text_properties, Fremove_list_of_text_properties) (Ftext_property_any, Ftext_property_not_all) (copy_text_properties, text_property_list, extend_property_ranges) (verify_interval_modification): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fnext_single_char_property_change) (Fprevious_single_char_property_change): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (copy_text_properties): Check for integer overflow in index calculation. * undo.c (last_boundary_position, record_point, record_insert) (record_delete, record_marker_adjustment, record_change) (record_property_change): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (truncate_undo_list, Fprimitive_undo): Don't assume fixnum fits in int. Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * w32fns.c (Fx_create_frame, x_create_tip_frame, Fx_show_tip) (Fx_hide_tip, Fx_file_dialog): * w32menu.c (set_frame_menubar): Use ptrdiff_t, not int, for consistency with rest of code. * window.c (window_scroll_preserve_hpos, window_scroll_preserve_vpos) (select_window, Fdelete_other_windows_internal) (window_scroll_pixel_based, window_scroll_line_based) (Frecenter, Fset_window_configuration): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (Fset_window_hscroll, run_window_configuration_change_hook) (set_window_buffer, temp_output_buffer_show, scroll_command) (Fscroll_other_window): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Fwindow_line_height, window_scroll, Fscroll_left, Fscroll_right): Don't assume fixnum fits in int. (Fset_window_scroll_bars): Check that fixnums are in proper range for system types. * xdisp.c (help_echo_pos, pos_visible_p, string_pos_nchars_ahead) (string_pos, c_string_pos, number_of_chars, init_iterator) (in_ellipses_for_invisible_text_p, init_from_display_pos) (compute_stop_pos, next_overlay_change, compute_display_string_pos) (compute_display_string_end, handle_face_prop) (face_before_or_after_it_pos, handle_invisible_prop, handle_display_prop) (handle_display_spec, handle_single_display_spec) (display_prop_intangible_p, string_buffer_position_lim) (string_buffer_position, handle_composition_prop, load_overlay_strings) (get_overlay_strings_1, get_overlay_strings) (iterate_out_of_display_property, forward_to_next_line_start) (back_to_previous_visible_line_start, reseat, reseat_to_string) (get_next_display_element, set_iterator_to_next) (get_visually_first_element, compute_stop_pos_backwards) (handle_stop_backwards, next_element_from_buffer) (move_it_in_display_line_to, move_it_in_display_line) (move_it_to, move_it_vertically_backward, move_it_by_lines) (add_to_log, message_dolog, message_log_check_duplicate) (message2, message2_nolog, message3, message3_nolog (with_echo_area_buffer, display_echo_area_1, resize_mini_window_1) (current_message_1, truncate_echo_area, truncate_message_1) (set_message, set_message_1, store_mode_line_noprop) (hscroll_window_tree, debug_delta, debug_delta_bytes, debug_end_vpos) (text_outside_line_unchanged_p, check_point_in_composition) (reconsider_clip_changes) (redisplay_internal, set_cursor_from_row, try_scrolling) (try_cursor_movement, set_vertical_scroll_bar, redisplay_window) (redisplay_window, find_last_unchanged_at_beg_row) (find_first_unchanged_at_end_row, row_containing_pos, try_window_id) (trailing_whitespace_p, find_row_edges, display_line) (RECORD_MAX_MIN_POS, Fcurrent_bidi_paragraph_direction) (display_mode_element, store_mode_line_string) (pint2str, pint2hrstr, decode_mode_spec) (display_count_lines, display_string, draw_glyphs) (x_produce_glyphs, x_insert_glyphs) (rows_from_pos_range, mouse_face_from_buffer_pos) (fast_find_string_pos, mouse_face_from_string_pos) (note_mode_line_or_margin_highlight, note_mouse_highlight): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (safe_call, init_from_display_pos, handle_fontified_prop) (handle_single_display_spec, load_overlay_strings) (with_echo_area_buffer, setup_echo_area_for_printing) (display_echo_area, echo_area_display) (x_consider_frame_title, prepare_menu_bars, update_menu_bar) (update_tool_bar, hscroll_window_tree, redisplay_internal) (redisplay_window, dump_glyph_row, display_mode_line, Fformat_mode_line) (decode_mode_spec, on_hot_spot_p): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (handle_single_display_spec, build_desired_tool_bar_string) (redisplay_tool_bar, scroll_window_tree, Fdump_glyph_matrix) (get_specified_cursor_type): Check that fixnums are in proper range for system types. (struct overlay_entry, resize_mini_window, Fdump_glyph_row) (Flookup_image_map): Don't assume fixnums fit in int. (compare_overlay_entries): Avoid mishandling comparisons due to subtraction overflow. (load_overlay_strings): Use SAFE_NALLOCA, not alloca. (last_escape_glyph_face_id, last_glyphless_glyph_face_id): (handle_tool_bar_click): Use int, not unsigned, since we prefer signed and the signedness doesn't matter here. (get_next_display_element, next_element_from_display_vector): Use int, not EMACS_INT, when int is wide enough. (start_hourglass): Use duration_to_sec_usec to do proper overflow checking on durations. * xfaces.c (Fbitmap_spec_p): Check that fixnums are in proper range for system types. (compare_fonts_by_sort_order): Avoid mishandling comparisons due to subtraction overflow. (Fx_family_fonts, realize_basic_faces): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Fx_family_fonts): Don't assume fixnum fits in int. Use SAFE_ALLOCA_LISP, not alloca. (merge_face_heights): Remove unnecessary cast to EMACS_INT. (Finternal_make_lisp_face): Don't allocate more than MAX_FACE_ID. (face_at_buffer_position, face_for_overlay_string) (face_at_string_position): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. (merge_faces): Use int, not EMACS_INT, where int is wide enough. * xfns.c (x_set_menu_bar_lines, x_set_tool_bar_lines, x_icon_verify) (Fx_show_tip): Check that fixnums are in proper range for system types. (Fx_create_frame, x_create_tip_frame, Fx_show_tip) (Fx_hide_tip, Fx_file_dialog, Fx_select_font): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (Fx_change_window_property): Don't assume fixnums fit in int. * xfont.c (xfont_chars_supported): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * xmenu.c (Fx_popup_dialog, set_frame_menubar) (create_and_show_popup_menu, create_and_show_dialog, xmenu_show): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * xml.c (parse_region): * xrdb.c (magic_file_p): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. * xselect.c (TRACE1): Don't assume pid_t promotes to int. (x_get_local_selection, x_reply_selection_request) (x_handle_selection_request, wait_for_property_change): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (selection_data_to_lisp_data): Use short, not EMACS_INT, where short is wide enough. (x_send_client_event): Don't assume fixnum fits in int. * xterm.c (x_x_to_emacs_modifiers): Don't assume EMACS_INT overflows nicely into int. (x_emacs_to_x_modifiers): Use EMACS_INT, not int, because values may come from Lisp. (handle_one_xevent): NATNUMP can eval its arg twice. (x_connection_closed): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * xterm.h: Adjust decls to match defn changes elsewhere. (struct scroll_bar): Use struct vectorlike_header rather than rolling our own approximation. (SCROLL_BAR_VEC_SIZE): Remove; not used.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c268
1 files changed, 136 insertions, 132 deletions
diff --git a/src/coding.c b/src/coding.c
index 5fd59d394d9..704d26f3f9b 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -159,7 +159,7 @@ detect_coding_XXX (struct coding_system *coding,
159 const unsigned char *src = coding->source; 159 const unsigned char *src = coding->source;
160 const unsigned char *src_end = coding->source + coding->src_bytes; 160 const unsigned char *src_end = coding->source + coding->src_bytes;
161 int multibytep = coding->src_multibyte; 161 int multibytep = coding->src_multibyte;
162 EMACS_INT consumed_chars = 0; 162 ptrdiff_t consumed_chars = 0;
163 int found = 0; 163 int found = 0;
164 ...; 164 ...;
165 165
@@ -266,7 +266,7 @@ encode_coding_XXX (struct coding_system *coding)
266 unsigned char *dst = coding->destination + coding->produced; 266 unsigned char *dst = coding->destination + coding->produced;
267 unsigned char *dst_end = coding->destination + coding->dst_bytes; 267 unsigned char *dst_end = coding->destination + coding->dst_bytes;
268 unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; 268 unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_;
269 EMACS_INT produced_chars = 0; 269 ptrdiff_t produced_chars = 0;
270 270
271 for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) 271 for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++)
272 { 272 {
@@ -849,31 +849,31 @@ static int encode_coding_raw_text (struct coding_system *);
849 849
850static void coding_set_source (struct coding_system *); 850static void coding_set_source (struct coding_system *);
851static void coding_set_destination (struct coding_system *); 851static void coding_set_destination (struct coding_system *);
852static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT); 852static void coding_alloc_by_realloc (struct coding_system *, ptrdiff_t);
853static void coding_alloc_by_making_gap (struct coding_system *, 853static void coding_alloc_by_making_gap (struct coding_system *,
854 EMACS_INT, EMACS_INT); 854 ptrdiff_t, ptrdiff_t);
855static unsigned char *alloc_destination (struct coding_system *, 855static unsigned char *alloc_destination (struct coding_system *,
856 EMACS_INT, unsigned char *); 856 ptrdiff_t, unsigned char *);
857static void setup_iso_safe_charsets (Lisp_Object); 857static void setup_iso_safe_charsets (Lisp_Object);
858static unsigned char *encode_designation_at_bol (struct coding_system *, 858static unsigned char *encode_designation_at_bol (struct coding_system *,
859 int *, unsigned char *); 859 int *, unsigned char *);
860static int detect_eol (const unsigned char *, 860static int detect_eol (const unsigned char *,
861 EMACS_INT, enum coding_category); 861 ptrdiff_t, enum coding_category);
862static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); 862static Lisp_Object adjust_coding_eol_type (struct coding_system *, int);
863static void decode_eol (struct coding_system *); 863static void decode_eol (struct coding_system *);
864static Lisp_Object get_translation_table (Lisp_Object, int, int *); 864static Lisp_Object get_translation_table (Lisp_Object, int, int *);
865static Lisp_Object get_translation (Lisp_Object, int *, int *); 865static Lisp_Object get_translation (Lisp_Object, int *, int *);
866static int produce_chars (struct coding_system *, Lisp_Object, int); 866static int produce_chars (struct coding_system *, Lisp_Object, int);
867static inline void produce_charset (struct coding_system *, int *, 867static inline void produce_charset (struct coding_system *, int *,
868 EMACS_INT); 868 ptrdiff_t);
869static void produce_annotation (struct coding_system *, EMACS_INT); 869static void produce_annotation (struct coding_system *, ptrdiff_t);
870static int decode_coding (struct coding_system *); 870static int decode_coding (struct coding_system *);
871static inline int *handle_composition_annotation (EMACS_INT, EMACS_INT, 871static inline int *handle_composition_annotation (ptrdiff_t, ptrdiff_t,
872 struct coding_system *, 872 struct coding_system *,
873 int *, EMACS_INT *); 873 int *, ptrdiff_t *);
874static inline int *handle_charset_annotation (EMACS_INT, EMACS_INT, 874static inline int *handle_charset_annotation (ptrdiff_t, ptrdiff_t,
875 struct coding_system *, 875 struct coding_system *,
876 int *, EMACS_INT *); 876 int *, ptrdiff_t *);
877static void consume_chars (struct coding_system *, Lisp_Object, int); 877static void consume_chars (struct coding_system *, Lisp_Object, int);
878static int encode_coding (struct coding_system *); 878static int encode_coding (struct coding_system *);
879static Lisp_Object make_conversion_work_buffer (int); 879static Lisp_Object make_conversion_work_buffer (int);
@@ -926,7 +926,7 @@ record_conversion_result (struct coding_system *coding,
926 if (charset_map_loaded) \ 926 if (charset_map_loaded) \
927 { \ 927 { \
928 const unsigned char *orig = coding->source; \ 928 const unsigned char *orig = coding->source; \
929 EMACS_INT offset; \ 929 ptrdiff_t offset; \
930 \ 930 \
931 coding_set_source (coding); \ 931 coding_set_source (coding); \
932 offset = coding->source - orig; \ 932 offset = coding->source - orig; \
@@ -946,7 +946,7 @@ record_conversion_result (struct coding_system *coding,
946 do { \ 946 do { \
947 if (dst + (bytes) >= dst_end) \ 947 if (dst + (bytes) >= dst_end) \
948 { \ 948 { \
949 EMACS_INT more_bytes = charbuf_end - charbuf + (bytes); \ 949 ptrdiff_t more_bytes = charbuf_end - charbuf + (bytes); \
950 \ 950 \
951 dst = alloc_destination (coding, more_bytes, dst); \ 951 dst = alloc_destination (coding, more_bytes, dst); \
952 dst_end = coding->destination + coding->dst_bytes; \ 952 dst_end = coding->destination + coding->dst_bytes; \
@@ -1069,7 +1069,7 @@ coding_set_destination (struct coding_system *coding)
1069 1069
1070 1070
1071static void 1071static void
1072coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) 1072coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes)
1073{ 1073{
1074 if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) 1074 if (STRING_BYTES_BOUND - coding->dst_bytes < bytes)
1075 string_overflow (); 1075 string_overflow ();
@@ -1080,7 +1080,7 @@ coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
1080 1080
1081static void 1081static void
1082coding_alloc_by_making_gap (struct coding_system *coding, 1082coding_alloc_by_making_gap (struct coding_system *coding,
1083 EMACS_INT gap_head_used, EMACS_INT bytes) 1083 ptrdiff_t gap_head_used, ptrdiff_t bytes)
1084{ 1084{
1085 if (EQ (coding->src_object, coding->dst_object)) 1085 if (EQ (coding->src_object, coding->dst_object))
1086 { 1086 {
@@ -1088,7 +1088,7 @@ coding_alloc_by_making_gap (struct coding_system *coding,
1088 consumed data at the tail. To preserve those data, we at 1088 consumed data at the tail. To preserve those data, we at
1089 first make the gap size to zero, then increase the gap 1089 first make the gap size to zero, then increase the gap
1090 size. */ 1090 size. */
1091 EMACS_INT add = GAP_SIZE; 1091 ptrdiff_t add = GAP_SIZE;
1092 1092
1093 GPT += gap_head_used, GPT_BYTE += gap_head_used; 1093 GPT += gap_head_used, GPT_BYTE += gap_head_used;
1094 GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; 1094 GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add;
@@ -1109,10 +1109,10 @@ coding_alloc_by_making_gap (struct coding_system *coding,
1109 1109
1110 1110
1111static unsigned char * 1111static unsigned char *
1112alloc_destination (struct coding_system *coding, EMACS_INT nbytes, 1112alloc_destination (struct coding_system *coding, ptrdiff_t nbytes,
1113 unsigned char *dst) 1113 unsigned char *dst)
1114{ 1114{
1115 EMACS_INT offset = dst - coding->destination; 1115 ptrdiff_t offset = dst - coding->destination;
1116 1116
1117 if (BUFFERP (coding->dst_object)) 1117 if (BUFFERP (coding->dst_object))
1118 { 1118 {
@@ -1213,7 +1213,7 @@ detect_coding_utf_8 (struct coding_system *coding,
1213 const unsigned char *src = coding->source, *src_base; 1213 const unsigned char *src = coding->source, *src_base;
1214 const unsigned char *src_end = coding->source + coding->src_bytes; 1214 const unsigned char *src_end = coding->source + coding->src_bytes;
1215 int multibytep = coding->src_multibyte; 1215 int multibytep = coding->src_multibyte;
1216 EMACS_INT consumed_chars = 0; 1216 ptrdiff_t consumed_chars = 0;
1217 int bom_found = 0; 1217 int bom_found = 0;
1218 int found = 0; 1218 int found = 0;
1219 1219
@@ -1298,7 +1298,7 @@ decode_coding_utf_8 (struct coding_system *coding)
1298 const unsigned char *src_base; 1298 const unsigned char *src_base;
1299 int *charbuf = coding->charbuf + coding->charbuf_used; 1299 int *charbuf = coding->charbuf + coding->charbuf_used;
1300 int *charbuf_end = coding->charbuf + coding->charbuf_size; 1300 int *charbuf_end = coding->charbuf + coding->charbuf_size;
1301 EMACS_INT consumed_chars = 0, consumed_chars_base = 0; 1301 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0;
1302 int multibytep = coding->src_multibyte; 1302 int multibytep = coding->src_multibyte;
1303 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); 1303 enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
1304 int eol_dos = 1304 int eol_dos =
@@ -1449,7 +1449,7 @@ encode_coding_utf_8 (struct coding_system *coding)
1449 int *charbuf_end = charbuf + coding->charbuf_used; 1449 int *charbuf_end = charbuf + coding->charbuf_used;
1450 unsigned char *dst = coding->destination + coding->produced; 1450 unsigned char *dst = coding->destination + coding->produced;
1451 unsigned char *dst_end = coding->destination + coding->dst_bytes; 1451 unsigned char *dst_end = coding->destination + coding->dst_bytes;
1452 EMACS_INT produced_chars = 0; 1452 ptrdiff_t produced_chars = 0;
1453 int c; 1453 int c;
1454 1454
1455 if (CODING_UTF_8_BOM (coding) == utf_with_bom) 1455 if (CODING_UTF_8_BOM (coding) == utf_with_bom)
@@ -1607,7 +1607,7 @@ decode_coding_utf_16 (struct coding_system *coding)
1607 int *charbuf = coding->charbuf + coding->charbuf_used; 1607 int *charbuf = coding->charbuf + coding->charbuf_used;
1608 /* We may produces at most 3 chars in one loop. */ 1608 /* We may produces at most 3 chars in one loop. */
1609 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; 1609 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2;
1610 EMACS_INT consumed_chars = 0, consumed_chars_base = 0; 1610 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0;
1611 int multibytep = coding->src_multibyte; 1611 int multibytep = coding->src_multibyte;
1612 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1612 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1613 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); 1613 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
@@ -1734,7 +1734,7 @@ encode_coding_utf_16 (struct coding_system *coding)
1734 int safe_room = 8; 1734 int safe_room = 8;
1735 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1735 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1736 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; 1736 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
1737 EMACS_INT produced_chars = 0; 1737 ptrdiff_t produced_chars = 0;
1738 int c; 1738 int c;
1739 1739
1740 if (bom != utf_without_bom) 1740 if (bom != utf_without_bom)
@@ -1868,7 +1868,7 @@ detect_coding_emacs_mule (struct coding_system *coding,
1868 const unsigned char *src = coding->source, *src_base; 1868 const unsigned char *src = coding->source, *src_base;
1869 const unsigned char *src_end = coding->source + coding->src_bytes; 1869 const unsigned char *src_end = coding->source + coding->src_bytes;
1870 int multibytep = coding->src_multibyte; 1870 int multibytep = coding->src_multibyte;
1871 EMACS_INT consumed_chars = 0; 1871 ptrdiff_t consumed_chars = 0;
1872 int c; 1872 int c;
1873 int found = 0; 1873 int found = 0;
1874 1874
@@ -2338,10 +2338,10 @@ decode_coding_emacs_mule (struct coding_system *coding)
2338 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) 2338 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3)
2339 /* We can produce up to 2 characters in a loop. */ 2339 /* We can produce up to 2 characters in a loop. */
2340 - 1; 2340 - 1;
2341 EMACS_INT consumed_chars = 0, consumed_chars_base; 2341 ptrdiff_t consumed_chars = 0, consumed_chars_base;
2342 int multibytep = coding->src_multibyte; 2342 int multibytep = coding->src_multibyte;
2343 EMACS_INT char_offset = coding->produced_char; 2343 ptrdiff_t char_offset = coding->produced_char;
2344 EMACS_INT last_offset = char_offset; 2344 ptrdiff_t last_offset = char_offset;
2345 int last_id = charset_ascii; 2345 int last_id = charset_ascii;
2346 int eol_dos = 2346 int eol_dos =
2347 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 2347 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -2413,7 +2413,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
2413 original pointer to buffer text, and fix up all related 2413 original pointer to buffer text, and fix up all related
2414 pointers after the call. */ 2414 pointers after the call. */
2415 const unsigned char *orig = coding->source; 2415 const unsigned char *orig = coding->source;
2416 EMACS_INT offset; 2416 ptrdiff_t offset;
2417 2417
2418 c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id, 2418 c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id,
2419 cmp_status); 2419 cmp_status);
@@ -2594,7 +2594,7 @@ encode_coding_emacs_mule (struct coding_system *coding)
2594 unsigned char *dst = coding->destination + coding->produced; 2594 unsigned char *dst = coding->destination + coding->produced;
2595 unsigned char *dst_end = coding->destination + coding->dst_bytes; 2595 unsigned char *dst_end = coding->destination + coding->dst_bytes;
2596 int safe_room = 8; 2596 int safe_room = 8;
2597 EMACS_INT produced_chars = 0; 2597 ptrdiff_t produced_chars = 0;
2598 Lisp_Object attrs, charset_list; 2598 Lisp_Object attrs, charset_list;
2599 int c; 2599 int c;
2600 int preferred_charset_id = -1; 2600 int preferred_charset_id = -1;
@@ -2881,7 +2881,7 @@ setup_iso_safe_charsets (Lisp_Object attrs)
2881 Lisp_Object request; 2881 Lisp_Object request;
2882 Lisp_Object reg_usage; 2882 Lisp_Object reg_usage;
2883 Lisp_Object tail; 2883 Lisp_Object tail;
2884 int reg94, reg96; 2884 EMACS_INT reg94, reg96;
2885 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); 2885 int flags = XINT (AREF (attrs, coding_attr_iso_flags));
2886 int max_charset_id; 2886 int max_charset_id;
2887 2887
@@ -2952,7 +2952,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
2952 int single_shifting = 0; 2952 int single_shifting = 0;
2953 int id; 2953 int id;
2954 int c, c1; 2954 int c, c1;
2955 EMACS_INT consumed_chars = 0; 2955 ptrdiff_t consumed_chars = 0;
2956 int i; 2956 int i;
2957 int rejected = 0; 2957 int rejected = 0;
2958 int found = 0; 2958 int found = 0;
@@ -3462,7 +3462,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3462 loop and one more charset annotation at the end. */ 3462 loop and one more charset annotation at the end. */
3463 int *charbuf_end 3463 int *charbuf_end
3464 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); 3464 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
3465 EMACS_INT consumed_chars = 0, consumed_chars_base; 3465 ptrdiff_t consumed_chars = 0, consumed_chars_base;
3466 int multibytep = coding->src_multibyte; 3466 int multibytep = coding->src_multibyte;
3467 /* Charsets invoked to graphic plane 0 and 1 respectively. */ 3467 /* Charsets invoked to graphic plane 0 and 1 respectively. */
3468 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); 3468 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0);
@@ -3472,8 +3472,8 @@ decode_coding_iso_2022 (struct coding_system *coding)
3472 int c; 3472 int c;
3473 struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); 3473 struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding);
3474 Lisp_Object attrs = CODING_ID_ATTRS (coding->id); 3474 Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
3475 EMACS_INT char_offset = coding->produced_char; 3475 ptrdiff_t char_offset = coding->produced_char;
3476 EMACS_INT last_offset = char_offset; 3476 ptrdiff_t last_offset = char_offset;
3477 int last_id = charset_ascii; 3477 int last_id = charset_ascii;
3478 int eol_dos = 3478 int eol_dos =
3479 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 3479 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -4201,10 +4201,10 @@ decode_coding_iso_2022 (struct coding_system *coding)
4201static unsigned char * 4201static unsigned char *
4202encode_invocation_designation (struct charset *charset, 4202encode_invocation_designation (struct charset *charset,
4203 struct coding_system *coding, 4203 struct coding_system *coding,
4204 unsigned char *dst, EMACS_INT *p_nchars) 4204 unsigned char *dst, ptrdiff_t *p_nchars)
4205{ 4205{
4206 int multibytep = coding->dst_multibyte; 4206 int multibytep = coding->dst_multibyte;
4207 EMACS_INT produced_chars = *p_nchars; 4207 ptrdiff_t produced_chars = *p_nchars;
4208 int reg; /* graphic register number */ 4208 int reg; /* graphic register number */
4209 int id = CHARSET_ID (charset); 4209 int id = CHARSET_ID (charset);
4210 4210
@@ -4296,7 +4296,7 @@ encode_designation_at_bol (struct coding_system *coding, int *charbuf,
4296 /* Table of charsets to be designated to each graphic register. */ 4296 /* Table of charsets to be designated to each graphic register. */
4297 int r[4]; 4297 int r[4];
4298 int c, found = 0, reg; 4298 int c, found = 0, reg;
4299 EMACS_INT produced_chars = 0; 4299 ptrdiff_t produced_chars = 0;
4300 int multibytep = coding->dst_multibyte; 4300 int multibytep = coding->dst_multibyte;
4301 Lisp_Object attrs; 4301 Lisp_Object attrs;
4302 Lisp_Object charset_list; 4302 Lisp_Object charset_list;
@@ -4351,7 +4351,7 @@ encode_coding_iso_2022 (struct coding_system *coding)
4351 int bol_designation 4351 int bol_designation
4352 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL 4352 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL
4353 && CODING_ISO_BOL (coding)); 4353 && CODING_ISO_BOL (coding));
4354 EMACS_INT produced_chars = 0; 4354 ptrdiff_t produced_chars = 0;
4355 Lisp_Object attrs, eol_type, charset_list; 4355 Lisp_Object attrs, eol_type, charset_list;
4356 int ascii_compatible; 4356 int ascii_compatible;
4357 int c; 4357 int c;
@@ -4539,7 +4539,7 @@ detect_coding_sjis (struct coding_system *coding,
4539 const unsigned char *src = coding->source, *src_base; 4539 const unsigned char *src = coding->source, *src_base;
4540 const unsigned char *src_end = coding->source + coding->src_bytes; 4540 const unsigned char *src_end = coding->source + coding->src_bytes;
4541 int multibytep = coding->src_multibyte; 4541 int multibytep = coding->src_multibyte;
4542 EMACS_INT consumed_chars = 0; 4542 ptrdiff_t consumed_chars = 0;
4543 int found = 0; 4543 int found = 0;
4544 int c; 4544 int c;
4545 Lisp_Object attrs, charset_list; 4545 Lisp_Object attrs, charset_list;
@@ -4596,7 +4596,7 @@ detect_coding_big5 (struct coding_system *coding,
4596 const unsigned char *src = coding->source, *src_base; 4596 const unsigned char *src = coding->source, *src_base;
4597 const unsigned char *src_end = coding->source + coding->src_bytes; 4597 const unsigned char *src_end = coding->source + coding->src_bytes;
4598 int multibytep = coding->src_multibyte; 4598 int multibytep = coding->src_multibyte;
4599 EMACS_INT consumed_chars = 0; 4599 ptrdiff_t consumed_chars = 0;
4600 int found = 0; 4600 int found = 0;
4601 int c; 4601 int c;
4602 4602
@@ -4647,13 +4647,13 @@ decode_coding_sjis (struct coding_system *coding)
4647 the end. */ 4647 the end. */
4648 int *charbuf_end 4648 int *charbuf_end
4649 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 4649 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
4650 EMACS_INT consumed_chars = 0, consumed_chars_base; 4650 ptrdiff_t consumed_chars = 0, consumed_chars_base;
4651 int multibytep = coding->src_multibyte; 4651 int multibytep = coding->src_multibyte;
4652 struct charset *charset_roman, *charset_kanji, *charset_kana; 4652 struct charset *charset_roman, *charset_kanji, *charset_kana;
4653 struct charset *charset_kanji2; 4653 struct charset *charset_kanji2;
4654 Lisp_Object attrs, charset_list, val; 4654 Lisp_Object attrs, charset_list, val;
4655 EMACS_INT char_offset = coding->produced_char; 4655 ptrdiff_t char_offset = coding->produced_char;
4656 EMACS_INT last_offset = char_offset; 4656 ptrdiff_t last_offset = char_offset;
4657 int last_id = charset_ascii; 4657 int last_id = charset_ascii;
4658 int eol_dos = 4658 int eol_dos =
4659 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 4659 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -4765,12 +4765,12 @@ decode_coding_big5 (struct coding_system *coding)
4765 the end. */ 4765 the end. */
4766 int *charbuf_end 4766 int *charbuf_end
4767 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 4767 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
4768 EMACS_INT consumed_chars = 0, consumed_chars_base; 4768 ptrdiff_t consumed_chars = 0, consumed_chars_base;
4769 int multibytep = coding->src_multibyte; 4769 int multibytep = coding->src_multibyte;
4770 struct charset *charset_roman, *charset_big5; 4770 struct charset *charset_roman, *charset_big5;
4771 Lisp_Object attrs, charset_list, val; 4771 Lisp_Object attrs, charset_list, val;
4772 EMACS_INT char_offset = coding->produced_char; 4772 ptrdiff_t char_offset = coding->produced_char;
4773 EMACS_INT last_offset = char_offset; 4773 ptrdiff_t last_offset = char_offset;
4774 int last_id = charset_ascii; 4774 int last_id = charset_ascii;
4775 int eol_dos = 4775 int eol_dos =
4776 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 4776 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -4867,7 +4867,7 @@ encode_coding_sjis (struct coding_system *coding)
4867 unsigned char *dst = coding->destination + coding->produced; 4867 unsigned char *dst = coding->destination + coding->produced;
4868 unsigned char *dst_end = coding->destination + coding->dst_bytes; 4868 unsigned char *dst_end = coding->destination + coding->dst_bytes;
4869 int safe_room = 4; 4869 int safe_room = 4;
4870 EMACS_INT produced_chars = 0; 4870 ptrdiff_t produced_chars = 0;
4871 Lisp_Object attrs, charset_list, val; 4871 Lisp_Object attrs, charset_list, val;
4872 int ascii_compatible; 4872 int ascii_compatible;
4873 struct charset *charset_kanji, *charset_kana; 4873 struct charset *charset_kanji, *charset_kana;
@@ -4958,7 +4958,7 @@ encode_coding_big5 (struct coding_system *coding)
4958 unsigned char *dst = coding->destination + coding->produced; 4958 unsigned char *dst = coding->destination + coding->produced;
4959 unsigned char *dst_end = coding->destination + coding->dst_bytes; 4959 unsigned char *dst_end = coding->destination + coding->dst_bytes;
4960 int safe_room = 4; 4960 int safe_room = 4;
4961 EMACS_INT produced_chars = 0; 4961 ptrdiff_t produced_chars = 0;
4962 Lisp_Object attrs, charset_list, val; 4962 Lisp_Object attrs, charset_list, val;
4963 int ascii_compatible; 4963 int ascii_compatible;
4964 struct charset *charset_big5; 4964 struct charset *charset_big5;
@@ -5033,10 +5033,10 @@ detect_coding_ccl (struct coding_system *coding,
5033 const unsigned char *src = coding->source, *src_base; 5033 const unsigned char *src = coding->source, *src_base;
5034 const unsigned char *src_end = coding->source + coding->src_bytes; 5034 const unsigned char *src_end = coding->source + coding->src_bytes;
5035 int multibytep = coding->src_multibyte; 5035 int multibytep = coding->src_multibyte;
5036 EMACS_INT consumed_chars = 0; 5036 ptrdiff_t consumed_chars = 0;
5037 int found = 0; 5037 int found = 0;
5038 unsigned char *valids; 5038 unsigned char *valids;
5039 EMACS_INT head_ascii = coding->head_ascii; 5039 ptrdiff_t head_ascii = coding->head_ascii;
5040 Lisp_Object attrs; 5040 Lisp_Object attrs;
5041 5041
5042 detect_info->checked |= CATEGORY_MASK_CCL; 5042 detect_info->checked |= CATEGORY_MASK_CCL;
@@ -5073,7 +5073,7 @@ decode_coding_ccl (struct coding_system *coding)
5073 const unsigned char *src_end = coding->source + coding->src_bytes; 5073 const unsigned char *src_end = coding->source + coding->src_bytes;
5074 int *charbuf = coding->charbuf + coding->charbuf_used; 5074 int *charbuf = coding->charbuf + coding->charbuf_used;
5075 int *charbuf_end = coding->charbuf + coding->charbuf_size; 5075 int *charbuf_end = coding->charbuf + coding->charbuf_size;
5076 EMACS_INT consumed_chars = 0; 5076 ptrdiff_t consumed_chars = 0;
5077 int multibytep = coding->src_multibyte; 5077 int multibytep = coding->src_multibyte;
5078 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5078 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5079 int source_charbuf[1024]; 5079 int source_charbuf[1024];
@@ -5145,7 +5145,7 @@ encode_coding_ccl (struct coding_system *coding)
5145 unsigned char *dst = coding->destination + coding->produced; 5145 unsigned char *dst = coding->destination + coding->produced;
5146 unsigned char *dst_end = coding->destination + coding->dst_bytes; 5146 unsigned char *dst_end = coding->destination + coding->dst_bytes;
5147 int destination_charbuf[1024]; 5147 int destination_charbuf[1024];
5148 EMACS_INT produced_chars = 0; 5148 ptrdiff_t produced_chars = 0;
5149 int i; 5149 int i;
5150 Lisp_Object attrs, charset_list; 5150 Lisp_Object attrs, charset_list;
5151 5151
@@ -5232,7 +5232,7 @@ encode_coding_raw_text (struct coding_system *coding)
5232 int *charbuf_end = coding->charbuf + coding->charbuf_used; 5232 int *charbuf_end = coding->charbuf + coding->charbuf_used;
5233 unsigned char *dst = coding->destination + coding->produced; 5233 unsigned char *dst = coding->destination + coding->produced;
5234 unsigned char *dst_end = coding->destination + coding->dst_bytes; 5234 unsigned char *dst_end = coding->destination + coding->dst_bytes;
5235 EMACS_INT produced_chars = 0; 5235 ptrdiff_t produced_chars = 0;
5236 int c; 5236 int c;
5237 5237
5238 if (multibytep) 5238 if (multibytep)
@@ -5315,10 +5315,10 @@ detect_coding_charset (struct coding_system *coding,
5315 const unsigned char *src = coding->source, *src_base; 5315 const unsigned char *src = coding->source, *src_base;
5316 const unsigned char *src_end = coding->source + coding->src_bytes; 5316 const unsigned char *src_end = coding->source + coding->src_bytes;
5317 int multibytep = coding->src_multibyte; 5317 int multibytep = coding->src_multibyte;
5318 EMACS_INT consumed_chars = 0; 5318 ptrdiff_t consumed_chars = 0;
5319 Lisp_Object attrs, valids, name; 5319 Lisp_Object attrs, valids, name;
5320 int found = 0; 5320 int found = 0;
5321 EMACS_INT head_ascii = coding->head_ascii; 5321 ptrdiff_t head_ascii = coding->head_ascii;
5322 int check_latin_extra = 0; 5322 int check_latin_extra = 0;
5323 5323
5324 detect_info->checked |= CATEGORY_MASK_CHARSET; 5324 detect_info->checked |= CATEGORY_MASK_CHARSET;
@@ -5422,12 +5422,12 @@ decode_coding_charset (struct coding_system *coding)
5422 the end. */ 5422 the end. */
5423 int *charbuf_end 5423 int *charbuf_end
5424 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 5424 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
5425 EMACS_INT consumed_chars = 0, consumed_chars_base; 5425 ptrdiff_t consumed_chars = 0, consumed_chars_base;
5426 int multibytep = coding->src_multibyte; 5426 int multibytep = coding->src_multibyte;
5427 Lisp_Object attrs = CODING_ID_ATTRS (coding->id); 5427 Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
5428 Lisp_Object valids; 5428 Lisp_Object valids;
5429 EMACS_INT char_offset = coding->produced_char; 5429 ptrdiff_t char_offset = coding->produced_char;
5430 EMACS_INT last_offset = char_offset; 5430 ptrdiff_t last_offset = char_offset;
5431 int last_id = charset_ascii; 5431 int last_id = charset_ascii;
5432 int eol_dos = 5432 int eol_dos =
5433 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5433 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -5548,7 +5548,7 @@ encode_coding_charset (struct coding_system *coding)
5548 unsigned char *dst = coding->destination + coding->produced; 5548 unsigned char *dst = coding->destination + coding->produced;
5549 unsigned char *dst_end = coding->destination + coding->dst_bytes; 5549 unsigned char *dst_end = coding->destination + coding->dst_bytes;
5550 int safe_room = MAX_MULTIBYTE_LENGTH; 5550 int safe_room = MAX_MULTIBYTE_LENGTH;
5551 EMACS_INT produced_chars = 0; 5551 ptrdiff_t produced_chars = 0;
5552 Lisp_Object attrs, charset_list; 5552 Lisp_Object attrs, charset_list;
5553 int ascii_compatible; 5553 int ascii_compatible;
5554 int c; 5554 int c;
@@ -6095,7 +6095,7 @@ complement_process_encoding_system (Lisp_Object coding_system)
6095#define MAX_EOL_CHECK_COUNT 3 6095#define MAX_EOL_CHECK_COUNT 3
6096 6096
6097static int 6097static int
6098detect_eol (const unsigned char *source, EMACS_INT src_bytes, 6098detect_eol (const unsigned char *source, ptrdiff_t src_bytes,
6099 enum coding_category category) 6099 enum coding_category category)
6100{ 6100{
6101 const unsigned char *src = source, *src_end = src + src_bytes; 6101 const unsigned char *src = source, *src_end = src + src_bytes;
@@ -6456,7 +6456,7 @@ decode_eol (struct coding_system *coding)
6456 } 6456 }
6457 else if (EQ (eol_type, Qdos)) 6457 else if (EQ (eol_type, Qdos))
6458 { 6458 {
6459 EMACS_INT n = 0; 6459 ptrdiff_t n = 0;
6460 6460
6461 if (NILP (coding->dst_object)) 6461 if (NILP (coding->dst_object))
6462 { 6462 {
@@ -6471,9 +6471,9 @@ decode_eol (struct coding_system *coding)
6471 } 6471 }
6472 else 6472 else
6473 { 6473 {
6474 EMACS_INT pos_byte = coding->dst_pos_byte; 6474 ptrdiff_t pos_byte = coding->dst_pos_byte;
6475 EMACS_INT pos = coding->dst_pos; 6475 ptrdiff_t pos = coding->dst_pos;
6476 EMACS_INT pos_end = pos + coding->produced_char - 1; 6476 ptrdiff_t pos_end = pos + coding->produced_char - 1;
6477 6477
6478 while (pos < pos_end) 6478 while (pos < pos_end)
6479 { 6479 {
@@ -6636,8 +6636,8 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6636{ 6636{
6637 unsigned char *dst = coding->destination + coding->produced; 6637 unsigned char *dst = coding->destination + coding->produced;
6638 unsigned char *dst_end = coding->destination + coding->dst_bytes; 6638 unsigned char *dst_end = coding->destination + coding->dst_bytes;
6639 EMACS_INT produced; 6639 ptrdiff_t produced;
6640 EMACS_INT produced_chars = 0; 6640 ptrdiff_t produced_chars = 0;
6641 int carryover = 0; 6641 int carryover = 0;
6642 6642
6643 if (! coding->chars_at_source) 6643 if (! coding->chars_at_source)
@@ -6658,7 +6658,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6658 6658
6659 if (c >= 0) 6659 if (c >= 0)
6660 { 6660 {
6661 EMACS_INT from_nchars = 1, to_nchars = 1; 6661 ptrdiff_t from_nchars = 1, to_nchars = 1;
6662 Lisp_Object trans = Qnil; 6662 Lisp_Object trans = Qnil;
6663 6663
6664 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); 6664 LOOKUP_TRANSLATION_TABLE (translation_table, c, trans);
@@ -6735,7 +6735,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6735 if (coding->src_multibyte) 6735 if (coding->src_multibyte)
6736 { 6736 {
6737 int multibytep = 1; 6737 int multibytep = 1;
6738 EMACS_INT consumed_chars = 0; 6738 ptrdiff_t consumed_chars = 0;
6739 6739
6740 while (1) 6740 while (1)
6741 { 6741 {
@@ -6749,7 +6749,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6749 dst_end = (unsigned char *) src; 6749 dst_end = (unsigned char *) src;
6750 if (dst == dst_end) 6750 if (dst == dst_end)
6751 { 6751 {
6752 EMACS_INT offset = src - coding->source; 6752 ptrdiff_t offset = src - coding->source;
6753 6753
6754 dst = alloc_destination (coding, src_end - src + 1, 6754 dst = alloc_destination (coding, src_end - src + 1,
6755 dst); 6755 dst);
@@ -6779,8 +6779,8 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6779 dst_end = (unsigned char *) src; 6779 dst_end = (unsigned char *) src;
6780 if (dst >= dst_end - 1) 6780 if (dst >= dst_end - 1)
6781 { 6781 {
6782 EMACS_INT offset = src - coding->source; 6782 ptrdiff_t offset = src - coding->source;
6783 EMACS_INT more_bytes; 6783 ptrdiff_t more_bytes;
6784 6784
6785 if (EQ (coding->src_object, coding->dst_object)) 6785 if (EQ (coding->src_object, coding->dst_object))
6786 more_bytes = ((src_end - src) / 2) + 2; 6786 more_bytes = ((src_end - src) / 2) + 2;
@@ -6802,11 +6802,11 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6802 { 6802 {
6803 if (!EQ (coding->src_object, coding->dst_object)) 6803 if (!EQ (coding->src_object, coding->dst_object))
6804 { 6804 {
6805 EMACS_INT require = coding->src_bytes - coding->dst_bytes; 6805 ptrdiff_t require = coding->src_bytes - coding->dst_bytes;
6806 6806
6807 if (require > 0) 6807 if (require > 0)
6808 { 6808 {
6809 EMACS_INT offset = src - coding->source; 6809 ptrdiff_t offset = src - coding->source;
6810 6810
6811 dst = alloc_destination (coding, require, dst); 6811 dst = alloc_destination (coding, require, dst);
6812 coding_set_source (coding); 6812 coding_set_source (coding);
@@ -6834,10 +6834,10 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6834 */ 6834 */
6835 6835
6836static inline void 6836static inline void
6837produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) 6837produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6838{ 6838{
6839 int len; 6839 int len;
6840 EMACS_INT to; 6840 ptrdiff_t to;
6841 enum composition_method method; 6841 enum composition_method method;
6842 Lisp_Object components; 6842 Lisp_Object components;
6843 6843
@@ -6878,9 +6878,9 @@ produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos)
6878 */ 6878 */
6879 6879
6880static inline void 6880static inline void
6881produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) 6881produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6882{ 6882{
6883 EMACS_INT from = pos - charbuf[2]; 6883 ptrdiff_t from = pos - charbuf[2];
6884 struct charset *charset = CHARSET_FROM_ID (charbuf[3]); 6884 struct charset *charset = CHARSET_FROM_ID (charbuf[3]);
6885 6885
6886 Fput_text_property (make_number (from), make_number (pos), 6886 Fput_text_property (make_number (from), make_number (pos),
@@ -6913,7 +6913,7 @@ produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos)
6913 6913
6914 6914
6915static void 6915static void
6916produce_annotation (struct coding_system *coding, EMACS_INT pos) 6916produce_annotation (struct coding_system *coding, ptrdiff_t pos)
6917{ 6917{
6918 int *charbuf = coding->charbuf; 6918 int *charbuf = coding->charbuf;
6919 int *charbuf_end = charbuf + coding->charbuf_used; 6919 int *charbuf_end = charbuf + coding->charbuf_used;
@@ -7013,7 +7013,7 @@ decode_coding (struct coding_system *coding)
7013 } 7013 }
7014 do 7014 do
7015 { 7015 {
7016 EMACS_INT pos = coding->dst_pos + coding->produced_char; 7016 ptrdiff_t pos = coding->dst_pos + coding->produced_char;
7017 7017
7018 coding_set_source (coding); 7018 coding_set_source (coding);
7019 coding->annotated = 0; 7019 coding->annotated = 0;
@@ -7106,11 +7106,11 @@ decode_coding (struct coding_system *coding)
7106 return BUF. */ 7106 return BUF. */
7107 7107
7108static inline int * 7108static inline int *
7109handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, 7109handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7110 struct coding_system *coding, int *buf, 7110 struct coding_system *coding, int *buf,
7111 EMACS_INT *stop) 7111 ptrdiff_t *stop)
7112{ 7112{
7113 EMACS_INT start, end; 7113 ptrdiff_t start, end;
7114 Lisp_Object prop; 7114 Lisp_Object prop;
7115 7115
7116 if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) 7116 if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object)
@@ -7189,9 +7189,9 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit,
7189 property value is non-nil (limiting by LIMIT), and return BUF. */ 7189 property value is non-nil (limiting by LIMIT), and return BUF. */
7190 7190
7191static inline int * 7191static inline int *
7192handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, 7192handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit,
7193 struct coding_system *coding, int *buf, 7193 struct coding_system *coding, int *buf,
7194 EMACS_INT *stop) 7194 ptrdiff_t *stop)
7195{ 7195{
7196 Lisp_Object val, next; 7196 Lisp_Object val, next;
7197 int id; 7197 int id;
@@ -7218,12 +7218,12 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7218 int *buf_end = coding->charbuf + coding->charbuf_size; 7218 int *buf_end = coding->charbuf + coding->charbuf_size;
7219 const unsigned char *src = coding->source + coding->consumed; 7219 const unsigned char *src = coding->source + coding->consumed;
7220 const unsigned char *src_end = coding->source + coding->src_bytes; 7220 const unsigned char *src_end = coding->source + coding->src_bytes;
7221 EMACS_INT pos = coding->src_pos + coding->consumed_char; 7221 ptrdiff_t pos = coding->src_pos + coding->consumed_char;
7222 EMACS_INT end_pos = coding->src_pos + coding->src_chars; 7222 ptrdiff_t end_pos = coding->src_pos + coding->src_chars;
7223 int multibytep = coding->src_multibyte; 7223 int multibytep = coding->src_multibyte;
7224 Lisp_Object eol_type; 7224 Lisp_Object eol_type;
7225 int c; 7225 int c;
7226 EMACS_INT stop, stop_composition, stop_charset; 7226 ptrdiff_t stop, stop_composition, stop_charset;
7227 int *lookup_buf = NULL; 7227 int *lookup_buf = NULL;
7228 7228
7229 if (! NILP (translation_table)) 7229 if (! NILP (translation_table))
@@ -7272,7 +7272,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7272 7272
7273 if (! multibytep) 7273 if (! multibytep)
7274 { 7274 {
7275 EMACS_INT bytes; 7275 int bytes;
7276 7276
7277 if (coding->encoder == encode_coding_raw_text 7277 if (coding->encoder == encode_coding_raw_text
7278 || coding->encoder == encode_coding_ccl) 7278 || coding->encoder == encode_coding_ccl)
@@ -7498,9 +7498,9 @@ code_conversion_save (int with_work_buf, int multibyte)
7498 7498
7499int 7499int
7500decode_coding_gap (struct coding_system *coding, 7500decode_coding_gap (struct coding_system *coding,
7501 EMACS_INT chars, EMACS_INT bytes) 7501 ptrdiff_t chars, ptrdiff_t bytes)
7502{ 7502{
7503 int count = SPECPDL_INDEX (); 7503 ptrdiff_t count = SPECPDL_INDEX ();
7504 Lisp_Object attrs; 7504 Lisp_Object attrs;
7505 7505
7506 code_conversion_save (0, 0); 7506 code_conversion_save (0, 0);
@@ -7527,7 +7527,7 @@ decode_coding_gap (struct coding_system *coding,
7527 attrs = CODING_ID_ATTRS (coding->id); 7527 attrs = CODING_ID_ATTRS (coding->id);
7528 if (! NILP (CODING_ATTR_POST_READ (attrs))) 7528 if (! NILP (CODING_ATTR_POST_READ (attrs)))
7529 { 7529 {
7530 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; 7530 ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
7531 Lisp_Object val; 7531 Lisp_Object val;
7532 7532
7533 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); 7533 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte);
@@ -7575,15 +7575,15 @@ decode_coding_gap (struct coding_system *coding,
7575void 7575void
7576decode_coding_object (struct coding_system *coding, 7576decode_coding_object (struct coding_system *coding,
7577 Lisp_Object src_object, 7577 Lisp_Object src_object,
7578 EMACS_INT from, EMACS_INT from_byte, 7578 ptrdiff_t from, ptrdiff_t from_byte,
7579 EMACS_INT to, EMACS_INT to_byte, 7579 ptrdiff_t to, ptrdiff_t to_byte,
7580 Lisp_Object dst_object) 7580 Lisp_Object dst_object)
7581{ 7581{
7582 int count = SPECPDL_INDEX (); 7582 ptrdiff_t count = SPECPDL_INDEX ();
7583 unsigned char *destination IF_LINT (= NULL); 7583 unsigned char *destination IF_LINT (= NULL);
7584 EMACS_INT dst_bytes IF_LINT (= 0); 7584 ptrdiff_t dst_bytes IF_LINT (= 0);
7585 EMACS_INT chars = to - from; 7585 ptrdiff_t chars = to - from;
7586 EMACS_INT bytes = to_byte - from_byte; 7586 ptrdiff_t bytes = to_byte - from_byte;
7587 Lisp_Object attrs; 7587 Lisp_Object attrs;
7588 int saved_pt = -1, saved_pt_byte IF_LINT (= 0); 7588 int saved_pt = -1, saved_pt_byte IF_LINT (= 0);
7589 int need_marker_adjustment = 0; 7589 int need_marker_adjustment = 0;
@@ -7676,7 +7676,7 @@ decode_coding_object (struct coding_system *coding,
7676 if (! NILP (CODING_ATTR_POST_READ (attrs))) 7676 if (! NILP (CODING_ATTR_POST_READ (attrs)))
7677 { 7677 {
7678 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 7678 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
7679 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; 7679 ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
7680 Lisp_Object val; 7680 Lisp_Object val;
7681 7681
7682 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); 7682 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte);
@@ -7765,13 +7765,13 @@ decode_coding_object (struct coding_system *coding,
7765void 7765void
7766encode_coding_object (struct coding_system *coding, 7766encode_coding_object (struct coding_system *coding,
7767 Lisp_Object src_object, 7767 Lisp_Object src_object,
7768 EMACS_INT from, EMACS_INT from_byte, 7768 ptrdiff_t from, ptrdiff_t from_byte,
7769 EMACS_INT to, EMACS_INT to_byte, 7769 ptrdiff_t to, ptrdiff_t to_byte,
7770 Lisp_Object dst_object) 7770 Lisp_Object dst_object)
7771{ 7771{
7772 int count = SPECPDL_INDEX (); 7772 ptrdiff_t count = SPECPDL_INDEX ();
7773 EMACS_INT chars = to - from; 7773 ptrdiff_t chars = to - from;
7774 EMACS_INT bytes = to_byte - from_byte; 7774 ptrdiff_t bytes = to_byte - from_byte;
7775 Lisp_Object attrs; 7775 Lisp_Object attrs;
7776 int saved_pt = -1, saved_pt_byte IF_LINT (= 0); 7776 int saved_pt = -1, saved_pt_byte IF_LINT (= 0);
7777 int need_marker_adjustment = 0; 7777 int need_marker_adjustment = 0;
@@ -8019,7 +8019,7 @@ are lower-case). */)
8019 (Lisp_Object prompt, Lisp_Object default_coding_system) 8019 (Lisp_Object prompt, Lisp_Object default_coding_system)
8020{ 8020{
8021 Lisp_Object val; 8021 Lisp_Object val;
8022 int count = SPECPDL_INDEX (); 8022 ptrdiff_t count = SPECPDL_INDEX ();
8023 8023
8024 if (SYMBOLP (default_coding_system)) 8024 if (SYMBOLP (default_coding_system))
8025 default_coding_system = SYMBOL_NAME (default_coding_system); 8025 default_coding_system = SYMBOL_NAME (default_coding_system);
@@ -8071,7 +8071,7 @@ function `define-coding-system'. */)
8071 8071
8072Lisp_Object 8072Lisp_Object
8073detect_coding_system (const unsigned char *src, 8073detect_coding_system (const unsigned char *src,
8074 EMACS_INT src_chars, EMACS_INT src_bytes, 8074 ptrdiff_t src_chars, ptrdiff_t src_bytes,
8075 int highest, int multibytep, 8075 int highest, int multibytep,
8076 Lisp_Object coding_system) 8076 Lisp_Object coding_system)
8077{ 8077{
@@ -8391,8 +8391,8 @@ If optional argument HIGHEST is non-nil, return the coding system of
8391highest priority. */) 8391highest priority. */)
8392 (Lisp_Object start, Lisp_Object end, Lisp_Object highest) 8392 (Lisp_Object start, Lisp_Object end, Lisp_Object highest)
8393{ 8393{
8394 int from, to; 8394 ptrdiff_t from, to;
8395 int from_byte, to_byte; 8395 ptrdiff_t from_byte, to_byte;
8396 8396
8397 CHECK_NUMBER_COERCE_MARKER (start); 8397 CHECK_NUMBER_COERCE_MARKER (start);
8398 CHECK_NUMBER_COERCE_MARKER (end); 8398 CHECK_NUMBER_COERCE_MARKER (end);
@@ -8472,7 +8472,7 @@ DEFUN ("find-coding-systems-region-internal",
8472 (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) 8472 (Lisp_Object start, Lisp_Object end, Lisp_Object exclude)
8473{ 8473{
8474 Lisp_Object coding_attrs_list, safe_codings; 8474 Lisp_Object coding_attrs_list, safe_codings;
8475 EMACS_INT start_byte, end_byte; 8475 ptrdiff_t start_byte, end_byte;
8476 const unsigned char *p, *pbeg, *pend; 8476 const unsigned char *p, *pbeg, *pend;
8477 int c; 8477 int c;
8478 Lisp_Object tail, elt, work_table; 8478 Lisp_Object tail, elt, work_table;
@@ -8566,7 +8566,7 @@ DEFUN ("find-coding-systems-region-internal",
8566 } 8566 }
8567 if (charset_map_loaded) 8567 if (charset_map_loaded)
8568 { 8568 {
8569 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; 8569 ptrdiff_t p_offset = p - pbeg, pend_offset = pend - pbeg;
8570 8570
8571 if (STRINGP (start)) 8571 if (STRINGP (start))
8572 pbeg = SDATA (start); 8572 pbeg = SDATA (start);
@@ -8604,11 +8604,11 @@ for un-encodable characters. In that case, START and END are indexes
8604to the string. */) 8604to the string. */)
8605 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) 8605 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string)
8606{ 8606{
8607 int n; 8607 EMACS_INT n;
8608 struct coding_system coding; 8608 struct coding_system coding;
8609 Lisp_Object attrs, charset_list, translation_table; 8609 Lisp_Object attrs, charset_list, translation_table;
8610 Lisp_Object positions; 8610 Lisp_Object positions;
8611 int from, to; 8611 ptrdiff_t from, to;
8612 const unsigned char *p, *stop, *pend; 8612 const unsigned char *p, *stop, *pend;
8613 int ascii_compatible; 8613 int ascii_compatible;
8614 8614
@@ -8641,11 +8641,10 @@ to the string. */)
8641 CHECK_STRING (string); 8641 CHECK_STRING (string);
8642 CHECK_NATNUM (start); 8642 CHECK_NATNUM (start);
8643 CHECK_NATNUM (end); 8643 CHECK_NATNUM (end);
8644 if (! (XINT (start) <= XINT (end) && XINT (end) <= SCHARS (string)))
8645 args_out_of_range_3 (string, start, end);
8644 from = XINT (start); 8646 from = XINT (start);
8645 to = XINT (end); 8647 to = XINT (end);
8646 if (from > to
8647 || to > SCHARS (string))
8648 args_out_of_range_3 (string, start, end);
8649 if (! STRING_MULTIBYTE (string)) 8648 if (! STRING_MULTIBYTE (string))
8650 return Qnil; 8649 return Qnil;
8651 p = SDATA (string) + string_char_to_byte (string, from); 8650 p = SDATA (string) + string_char_to_byte (string, from);
@@ -8720,8 +8719,8 @@ is nil. */)
8720 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) 8719 (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list)
8721{ 8720{
8722 Lisp_Object list; 8721 Lisp_Object list;
8723 EMACS_INT start_byte, end_byte; 8722 ptrdiff_t start_byte, end_byte;
8724 int pos; 8723 ptrdiff_t pos;
8725 const unsigned char *p, *pbeg, *pend; 8724 const unsigned char *p, *pbeg, *pend;
8726 int c; 8725 int c;
8727 Lisp_Object tail, elt, attrs; 8726 Lisp_Object tail, elt, attrs;
@@ -8794,7 +8793,7 @@ is nil. */)
8794 } 8793 }
8795 if (charset_map_loaded) 8794 if (charset_map_loaded)
8796 { 8795 {
8797 EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; 8796 ptrdiff_t p_offset = p - pbeg, pend_offset = pend - pbeg;
8798 8797
8799 if (STRINGP (start)) 8798 if (STRINGP (start))
8800 pbeg = SDATA (start); 8799 pbeg = SDATA (start);
@@ -8827,7 +8826,7 @@ code_convert_region (Lisp_Object start, Lisp_Object end,
8827 int encodep, int norecord) 8826 int encodep, int norecord)
8828{ 8827{
8829 struct coding_system coding; 8828 struct coding_system coding;
8830 EMACS_INT from, from_byte, to, to_byte; 8829 ptrdiff_t from, from_byte, to, to_byte;
8831 Lisp_Object src_object; 8830 Lisp_Object src_object;
8832 8831
8833 CHECK_NUMBER_COERCE_MARKER (start); 8832 CHECK_NUMBER_COERCE_MARKER (start);
@@ -8915,7 +8914,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
8915 Lisp_Object dst_object, int encodep, int nocopy, int norecord) 8914 Lisp_Object dst_object, int encodep, int nocopy, int norecord)
8916{ 8915{
8917 struct coding_system coding; 8916 struct coding_system coding;
8918 EMACS_INT chars, bytes; 8917 ptrdiff_t chars, bytes;
8919 8918
8920 CHECK_STRING (string); 8919 CHECK_STRING (string);
8921 if (NILP (coding_system)) 8920 if (NILP (coding_system))
@@ -9290,7 +9289,7 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */)
9290 error ("Too few arguments"); 9289 error ("Too few arguments");
9291 operation = args[0]; 9290 operation = args[0];
9292 if (!SYMBOLP (operation) 9291 if (!SYMBOLP (operation)
9293 || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) 9292 || (target_idx = Fget (operation, Qtarget_idx), !NATNUMP (target_idx)))
9294 error ("Invalid first argument"); 9293 error ("Invalid first argument");
9295 if (nargs < 1 + XFASTINT (target_idx)) 9294 if (nargs < 1 + XFASTINT (target_idx))
9296 error ("Too few arguments for operation `%s'", 9295 error ("Too few arguments for operation `%s'",
@@ -9511,8 +9510,12 @@ usage: (define-coding-system-internal ...) */)
9511 charset_list = Vemacs_mule_charset_list; 9510 charset_list = Vemacs_mule_charset_list;
9512 } 9511 }
9513 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) 9512 for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
9514 if (max_charset_id < XFASTINT (XCAR (tail))) 9513 {
9515 max_charset_id = XFASTINT (XCAR (tail)); 9514 if (! RANGED_INTEGERP (0, XCAR (tail), INT_MAX - 1))
9515 error ("Invalid charset-list");
9516 if (max_charset_id < XFASTINT (XCAR (tail)))
9517 max_charset_id = XFASTINT (XCAR (tail));
9518 }
9516 } 9519 }
9517 else 9520 else
9518 { 9521 {
@@ -9672,23 +9675,23 @@ usage: (define-coding-system-internal ...) */)
9672 val = Fcar (tail); 9675 val = Fcar (tail);
9673 if (INTEGERP (val)) 9676 if (INTEGERP (val))
9674 { 9677 {
9675 from = to = XINT (val); 9678 if (! (0 <= XINT (val) && XINT (val) <= 255))
9676 if (from < 0 || from > 255)
9677 args_out_of_range_3 (val, make_number (0), make_number (255)); 9679 args_out_of_range_3 (val, make_number (0), make_number (255));
9680 from = to = XINT (val);
9678 } 9681 }
9679 else 9682 else
9680 { 9683 {
9681 CHECK_CONS (val); 9684 CHECK_CONS (val);
9682 CHECK_NATNUM_CAR (val); 9685 CHECK_NATNUM_CAR (val);
9683 CHECK_NATNUM_CDR (val); 9686 CHECK_NUMBER_CDR (val);
9684 from = XINT (XCAR (val)); 9687 if (XINT (XCAR (val)) > 255)
9685 if (from > 255)
9686 args_out_of_range_3 (XCAR (val), 9688 args_out_of_range_3 (XCAR (val),
9687 make_number (0), make_number (255)); 9689 make_number (0), make_number (255));
9688 to = XINT (XCDR (val)); 9690 from = XINT (XCAR (val));
9689 if (to < from || to > 255) 9691 if (! (from <= XINT (XCDR (val)) && XINT (XCDR (val)) <= 255))
9690 args_out_of_range_3 (XCDR (val), 9692 args_out_of_range_3 (XCDR (val),
9691 XCAR (val), make_number (255)); 9693 XCAR (val), make_number (255));
9694 to = XINT (XCDR (val));
9692 } 9695 }
9693 for (i = from; i <= to; i++) 9696 for (i = from; i <= to; i++)
9694 SSET (valids, i, 1); 9697 SSET (valids, i, 1);
@@ -9783,9 +9786,10 @@ usage: (define-coding-system-internal ...) */)
9783 9786
9784 flags = args[coding_arg_iso2022_flags]; 9787 flags = args[coding_arg_iso2022_flags];
9785 CHECK_NATNUM (flags); 9788 CHECK_NATNUM (flags);
9786 i = XINT (flags); 9789 i = XINT (flags) & INT_MAX;
9787 if (EQ (args[coding_arg_charset_list], Qiso_2022)) 9790 if (EQ (args[coding_arg_charset_list], Qiso_2022))
9788 flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); 9791 i |= CODING_ISO_FLAG_FULL_SUPPORT;
9792 flags = make_number (i);
9789 9793
9790 ASET (attrs, coding_attr_iso_initial, initial); 9794 ASET (attrs, coding_attr_iso_initial, initial);
9791 ASET (attrs, coding_attr_iso_usage, reg_usage); 9795 ASET (attrs, coding_attr_iso_usage, reg_usage);