aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.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/fns.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/fns.c')
-rw-r--r--src/fns.c327
1 files changed, 165 insertions, 162 deletions
diff --git a/src/fns.c b/src/fns.c
index 392f447a6d8..5d75c42aea0 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -250,8 +250,8 @@ If string STR1 is greater, the value is a positive number N;
250 N - 1 is the number of characters that match at the beginning. */) 250 N - 1 is the number of characters that match at the beginning. */)
251 (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case) 251 (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case)
252{ 252{
253 register EMACS_INT end1_char, end2_char; 253 register ptrdiff_t end1_char, end2_char;
254 register EMACS_INT i1, i1_byte, i2, i2_byte; 254 register ptrdiff_t i1, i1_byte, i2, i2_byte;
255 255
256 CHECK_STRING (str1); 256 CHECK_STRING (str1);
257 CHECK_STRING (str2); 257 CHECK_STRING (str2);
@@ -266,19 +266,23 @@ If string STR1 is greater, the value is a positive number N;
266 if (! NILP (end2)) 266 if (! NILP (end2))
267 CHECK_NATNUM (end2); 267 CHECK_NATNUM (end2);
268 268
269 i1 = XINT (start1);
270 i2 = XINT (start2);
271
272 i1_byte = string_char_to_byte (str1, i1);
273 i2_byte = string_char_to_byte (str2, i2);
274
275 end1_char = SCHARS (str1); 269 end1_char = SCHARS (str1);
276 if (! NILP (end1) && end1_char > XINT (end1)) 270 if (! NILP (end1) && end1_char > XINT (end1))
277 end1_char = XINT (end1); 271 end1_char = XINT (end1);
272 if (end1_char < XINT (start1))
273 args_out_of_range (str1, start1);
278 274
279 end2_char = SCHARS (str2); 275 end2_char = SCHARS (str2);
280 if (! NILP (end2) && end2_char > XINT (end2)) 276 if (! NILP (end2) && end2_char > XINT (end2))
281 end2_char = XINT (end2); 277 end2_char = XINT (end2);
278 if (end2_char < XINT (start2))
279 args_out_of_range (str2, start2);
280
281 i1 = XINT (start1);
282 i2 = XINT (start2);
283
284 i1_byte = string_char_to_byte (str1, i1);
285 i2_byte = string_char_to_byte (str2, i2);
282 286
283 while (i1 < end1_char && i2 < end2_char) 287 while (i1 < end1_char && i2 < end2_char)
284 { 288 {
@@ -341,8 +345,8 @@ Case is significant.
341Symbols are also allowed; their print names are used instead. */) 345Symbols are also allowed; their print names are used instead. */)
342 (register Lisp_Object s1, Lisp_Object s2) 346 (register Lisp_Object s1, Lisp_Object s2)
343{ 347{
344 register EMACS_INT end; 348 register ptrdiff_t end;
345 register EMACS_INT i1, i1_byte, i2, i2_byte; 349 register ptrdiff_t i1, i1_byte, i2, i2_byte;
346 350
347 if (SYMBOLP (s1)) 351 if (SYMBOLP (s1))
348 s1 = SYMBOL_NAME (s1); 352 s1 = SYMBOL_NAME (s1);
@@ -465,8 +469,8 @@ with the original. */)
465struct textprop_rec 469struct textprop_rec
466{ 470{
467 ptrdiff_t argnum; /* refer to ARGS (arguments of `concat') */ 471 ptrdiff_t argnum; /* refer to ARGS (arguments of `concat') */
468 EMACS_INT from; /* refer to ARGS[argnum] (argument string) */ 472 ptrdiff_t from; /* refer to ARGS[argnum] (argument string) */
469 EMACS_INT to; /* refer to VAL (the target string) */ 473 ptrdiff_t to; /* refer to VAL (the target string) */
470}; 474};
471 475
472static Lisp_Object 476static Lisp_Object
@@ -476,8 +480,8 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
476 Lisp_Object val; 480 Lisp_Object val;
477 register Lisp_Object tail; 481 register Lisp_Object tail;
478 register Lisp_Object this; 482 register Lisp_Object this;
479 EMACS_INT toindex; 483 ptrdiff_t toindex;
480 EMACS_INT toindex_byte = 0; 484 ptrdiff_t toindex_byte = 0;
481 register EMACS_INT result_len; 485 register EMACS_INT result_len;
482 register EMACS_INT result_len_byte; 486 register EMACS_INT result_len_byte;
483 ptrdiff_t argnum; 487 ptrdiff_t argnum;
@@ -530,10 +534,10 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
530 { 534 {
531 /* We must count the number of bytes needed in the string 535 /* We must count the number of bytes needed in the string
532 as well as the number of characters. */ 536 as well as the number of characters. */
533 EMACS_INT i; 537 ptrdiff_t i;
534 Lisp_Object ch; 538 Lisp_Object ch;
535 int c; 539 int c;
536 EMACS_INT this_len_byte; 540 ptrdiff_t this_len_byte;
537 541
538 if (VECTORP (this) || COMPILEDP (this)) 542 if (VECTORP (this) || COMPILEDP (this))
539 for (i = 0; i < len; i++) 543 for (i = 0; i < len; i++)
@@ -542,6 +546,8 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
542 CHECK_CHARACTER (ch); 546 CHECK_CHARACTER (ch);
543 c = XFASTINT (ch); 547 c = XFASTINT (ch);
544 this_len_byte = CHAR_BYTES (c); 548 this_len_byte = CHAR_BYTES (c);
549 if (STRING_BYTES_BOUND - result_len_byte < this_len_byte)
550 string_overflow ();
545 result_len_byte += this_len_byte; 551 result_len_byte += this_len_byte;
546 if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c)) 552 if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c))
547 some_multibyte = 1; 553 some_multibyte = 1;
@@ -555,6 +561,8 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
555 CHECK_CHARACTER (ch); 561 CHECK_CHARACTER (ch);
556 c = XFASTINT (ch); 562 c = XFASTINT (ch);
557 this_len_byte = CHAR_BYTES (c); 563 this_len_byte = CHAR_BYTES (c);
564 if (STRING_BYTES_BOUND - result_len_byte < this_len_byte)
565 string_overflow ();
558 result_len_byte += this_len_byte; 566 result_len_byte += this_len_byte;
559 if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c)) 567 if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c))
560 some_multibyte = 1; 568 some_multibyte = 1;
@@ -564,17 +572,20 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
564 if (STRING_MULTIBYTE (this)) 572 if (STRING_MULTIBYTE (this))
565 { 573 {
566 some_multibyte = 1; 574 some_multibyte = 1;
567 result_len_byte += SBYTES (this); 575 this_len_byte = SBYTES (this);
568 } 576 }
569 else 577 else
570 result_len_byte += count_size_as_multibyte (SDATA (this), 578 this_len_byte = count_size_as_multibyte (SDATA (this),
571 SCHARS (this)); 579 SCHARS (this));
580 if (STRING_BYTES_BOUND - result_len_byte < this_len_byte)
581 string_overflow ();
582 result_len_byte += this_len_byte;
572 } 583 }
573 } 584 }
574 585
575 result_len += len; 586 result_len += len;
576 if (STRING_BYTES_BOUND < result_len) 587 if (MOST_POSITIVE_FIXNUM < result_len)
577 string_overflow (); 588 memory_full (SIZE_MAX);
578 } 589 }
579 590
580 if (! some_multibyte) 591 if (! some_multibyte)
@@ -607,9 +618,9 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
607 for (argnum = 0; argnum < nargs; argnum++) 618 for (argnum = 0; argnum < nargs; argnum++)
608 { 619 {
609 Lisp_Object thislen; 620 Lisp_Object thislen;
610 EMACS_INT thisleni = 0; 621 ptrdiff_t thisleni = 0;
611 register EMACS_INT thisindex = 0; 622 register ptrdiff_t thisindex = 0;
612 register EMACS_INT thisindex_byte = 0; 623 register ptrdiff_t thisindex_byte = 0;
613 624
614 this = args[argnum]; 625 this = args[argnum];
615 if (!CONSP (this)) 626 if (!CONSP (this))
@@ -619,7 +630,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
619 if (STRINGP (this) && STRINGP (val) 630 if (STRINGP (this) && STRINGP (val)
620 && STRING_MULTIBYTE (this) == some_multibyte) 631 && STRING_MULTIBYTE (this) == some_multibyte)
621 { 632 {
622 EMACS_INT thislen_byte = SBYTES (this); 633 ptrdiff_t thislen_byte = SBYTES (this);
623 634
624 memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); 635 memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this));
625 if (! NULL_INTERVAL_P (STRING_INTERVALS (this))) 636 if (! NULL_INTERVAL_P (STRING_INTERVALS (this)))
@@ -720,7 +731,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
720 if (num_textprops > 0) 731 if (num_textprops > 0)
721 { 732 {
722 Lisp_Object props; 733 Lisp_Object props;
723 EMACS_INT last_to_end = -1; 734 ptrdiff_t last_to_end = -1;
724 735
725 for (argnum = 0; argnum < num_textprops; argnum++) 736 for (argnum = 0; argnum < num_textprops; argnum++)
726 { 737 {
@@ -744,8 +755,8 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
744} 755}
745 756
746static Lisp_Object string_char_byte_cache_string; 757static Lisp_Object string_char_byte_cache_string;
747static EMACS_INT string_char_byte_cache_charpos; 758static ptrdiff_t string_char_byte_cache_charpos;
748static EMACS_INT string_char_byte_cache_bytepos; 759static ptrdiff_t string_char_byte_cache_bytepos;
749 760
750void 761void
751clear_string_char_byte_cache (void) 762clear_string_char_byte_cache (void)
@@ -755,12 +766,12 @@ clear_string_char_byte_cache (void)
755 766
756/* Return the byte index corresponding to CHAR_INDEX in STRING. */ 767/* Return the byte index corresponding to CHAR_INDEX in STRING. */
757 768
758EMACS_INT 769ptrdiff_t
759string_char_to_byte (Lisp_Object string, EMACS_INT char_index) 770string_char_to_byte (Lisp_Object string, ptrdiff_t char_index)
760{ 771{
761 EMACS_INT i_byte; 772 ptrdiff_t i_byte;
762 EMACS_INT best_below, best_below_byte; 773 ptrdiff_t best_below, best_below_byte;
763 EMACS_INT best_above, best_above_byte; 774 ptrdiff_t best_above, best_above_byte;
764 775
765 best_below = best_below_byte = 0; 776 best_below = best_below_byte = 0;
766 best_above = SCHARS (string); 777 best_above = SCHARS (string);
@@ -815,12 +826,12 @@ string_char_to_byte (Lisp_Object string, EMACS_INT char_index)
815 826
816/* Return the character index corresponding to BYTE_INDEX in STRING. */ 827/* Return the character index corresponding to BYTE_INDEX in STRING. */
817 828
818EMACS_INT 829ptrdiff_t
819string_byte_to_char (Lisp_Object string, EMACS_INT byte_index) 830string_byte_to_char (Lisp_Object string, ptrdiff_t byte_index)
820{ 831{
821 EMACS_INT i, i_byte; 832 ptrdiff_t i, i_byte;
822 EMACS_INT best_below, best_below_byte; 833 ptrdiff_t best_below, best_below_byte;
823 EMACS_INT best_above, best_above_byte; 834 ptrdiff_t best_above, best_above_byte;
824 835
825 best_below = best_below_byte = 0; 836 best_below = best_below_byte = 0;
826 best_above = SCHARS (string); 837 best_above = SCHARS (string);
@@ -883,7 +894,7 @@ static Lisp_Object
883string_make_multibyte (Lisp_Object string) 894string_make_multibyte (Lisp_Object string)
884{ 895{
885 unsigned char *buf; 896 unsigned char *buf;
886 EMACS_INT nbytes; 897 ptrdiff_t nbytes;
887 Lisp_Object ret; 898 Lisp_Object ret;
888 USE_SAFE_ALLOCA; 899 USE_SAFE_ALLOCA;
889 900
@@ -916,7 +927,7 @@ Lisp_Object
916string_to_multibyte (Lisp_Object string) 927string_to_multibyte (Lisp_Object string)
917{ 928{
918 unsigned char *buf; 929 unsigned char *buf;
919 EMACS_INT nbytes; 930 ptrdiff_t nbytes;
920 Lisp_Object ret; 931 Lisp_Object ret;
921 USE_SAFE_ALLOCA; 932 USE_SAFE_ALLOCA;
922 933
@@ -945,7 +956,7 @@ string_to_multibyte (Lisp_Object string)
945Lisp_Object 956Lisp_Object
946string_make_unibyte (Lisp_Object string) 957string_make_unibyte (Lisp_Object string)
947{ 958{
948 EMACS_INT nchars; 959 ptrdiff_t nchars;
949 unsigned char *buf; 960 unsigned char *buf;
950 Lisp_Object ret; 961 Lisp_Object ret;
951 USE_SAFE_ALLOCA; 962 USE_SAFE_ALLOCA;
@@ -1010,7 +1021,7 @@ If STRING is multibyte and contains a character of charset
1010 1021
1011 if (STRING_MULTIBYTE (string)) 1022 if (STRING_MULTIBYTE (string))
1012 { 1023 {
1013 EMACS_INT bytes = SBYTES (string); 1024 ptrdiff_t bytes = SBYTES (string);
1014 unsigned char *str = (unsigned char *) xmalloc (bytes); 1025 unsigned char *str = (unsigned char *) xmalloc (bytes);
1015 1026
1016 memcpy (str, SDATA (string), bytes); 1027 memcpy (str, SDATA (string), bytes);
@@ -1043,7 +1054,7 @@ If you're not sure, whether to use `string-as-multibyte' or
1043 if (! STRING_MULTIBYTE (string)) 1054 if (! STRING_MULTIBYTE (string))
1044 { 1055 {
1045 Lisp_Object new_string; 1056 Lisp_Object new_string;
1046 EMACS_INT nchars, nbytes; 1057 ptrdiff_t nchars, nbytes;
1047 1058
1048 parse_str_as_multibyte (SDATA (string), 1059 parse_str_as_multibyte (SDATA (string),
1049 SBYTES (string), 1060 SBYTES (string),
@@ -1092,9 +1103,9 @@ an error is signaled. */)
1092 1103
1093 if (STRING_MULTIBYTE (string)) 1104 if (STRING_MULTIBYTE (string))
1094 { 1105 {
1095 EMACS_INT chars = SCHARS (string); 1106 ptrdiff_t chars = SCHARS (string);
1096 unsigned char *str = (unsigned char *) xmalloc (chars); 1107 unsigned char *str = (unsigned char *) xmalloc (chars);
1097 EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0); 1108 ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0);
1098 1109
1099 if (converted < chars) 1110 if (converted < chars)
1100 error ("Can't convert the %"pI"dth character to unibyte", converted); 1111 error ("Can't convert the %"pI"dth character to unibyte", converted);
@@ -1145,27 +1156,19 @@ value is a new vector that contains the elements between index FROM
1145 (Lisp_Object string, register Lisp_Object from, Lisp_Object to) 1156 (Lisp_Object string, register Lisp_Object from, Lisp_Object to)
1146{ 1157{
1147 Lisp_Object res; 1158 Lisp_Object res;
1148 EMACS_INT size; 1159 ptrdiff_t size;
1149 EMACS_INT size_byte = 0;
1150 EMACS_INT from_char, to_char; 1160 EMACS_INT from_char, to_char;
1151 EMACS_INT from_byte = 0, to_byte = 0;
1152 1161
1153 CHECK_VECTOR_OR_STRING (string); 1162 CHECK_VECTOR_OR_STRING (string);
1154 CHECK_NUMBER (from); 1163 CHECK_NUMBER (from);
1155 1164
1156 if (STRINGP (string)) 1165 if (STRINGP (string))
1157 { 1166 size = SCHARS (string);
1158 size = SCHARS (string);
1159 size_byte = SBYTES (string);
1160 }
1161 else 1167 else
1162 size = ASIZE (string); 1168 size = ASIZE (string);
1163 1169
1164 if (NILP (to)) 1170 if (NILP (to))
1165 { 1171 to_char = size;
1166 to_char = size;
1167 to_byte = size_byte;
1168 }
1169 else 1172 else
1170 { 1173 {
1171 CHECK_NUMBER (to); 1174 CHECK_NUMBER (to);
@@ -1173,23 +1176,19 @@ value is a new vector that contains the elements between index FROM
1173 to_char = XINT (to); 1176 to_char = XINT (to);
1174 if (to_char < 0) 1177 if (to_char < 0)
1175 to_char += size; 1178 to_char += size;
1176
1177 if (STRINGP (string))
1178 to_byte = string_char_to_byte (string, to_char);
1179 } 1179 }
1180 1180
1181 from_char = XINT (from); 1181 from_char = XINT (from);
1182 if (from_char < 0) 1182 if (from_char < 0)
1183 from_char += size; 1183 from_char += size;
1184 if (STRINGP (string))
1185 from_byte = string_char_to_byte (string, from_char);
1186
1187 if (!(0 <= from_char && from_char <= to_char && to_char <= size)) 1184 if (!(0 <= from_char && from_char <= to_char && to_char <= size))
1188 args_out_of_range_3 (string, make_number (from_char), 1185 args_out_of_range_3 (string, make_number (from_char),
1189 make_number (to_char)); 1186 make_number (to_char));
1190
1191 if (STRINGP (string)) 1187 if (STRINGP (string))
1192 { 1188 {
1189 ptrdiff_t to_byte =
1190 (NILP (to) ? SBYTES (string) : string_char_to_byte (string, to_char));
1191 ptrdiff_t from_byte = string_char_to_byte (string, from_char);
1193 res = make_specified_string (SSDATA (string) + from_byte, 1192 res = make_specified_string (SSDATA (string) + from_byte,
1194 to_char - from_char, to_byte - from_byte, 1193 to_char - from_char, to_byte - from_byte,
1195 STRING_MULTIBYTE (string)); 1194 STRING_MULTIBYTE (string));
@@ -1213,47 +1212,41 @@ If FROM or TO is negative, it counts from the end.
1213With one argument, just copy STRING without its properties. */) 1212With one argument, just copy STRING without its properties. */)
1214 (Lisp_Object string, register Lisp_Object from, Lisp_Object to) 1213 (Lisp_Object string, register Lisp_Object from, Lisp_Object to)
1215{ 1214{
1216 EMACS_INT size, size_byte; 1215 ptrdiff_t size;
1217 EMACS_INT from_char, to_char; 1216 EMACS_INT from_char, to_char;
1218 EMACS_INT from_byte, to_byte; 1217 ptrdiff_t from_byte, to_byte;
1219 1218
1220 CHECK_STRING (string); 1219 CHECK_STRING (string);
1221 1220
1222 size = SCHARS (string); 1221 size = SCHARS (string);
1223 size_byte = SBYTES (string);
1224 1222
1225 if (NILP (from)) 1223 if (NILP (from))
1226 from_char = from_byte = 0; 1224 from_char = 0;
1227 else 1225 else
1228 { 1226 {
1229 CHECK_NUMBER (from); 1227 CHECK_NUMBER (from);
1230 from_char = XINT (from); 1228 from_char = XINT (from);
1231 if (from_char < 0) 1229 if (from_char < 0)
1232 from_char += size; 1230 from_char += size;
1233
1234 from_byte = string_char_to_byte (string, from_char);
1235 } 1231 }
1236 1232
1237 if (NILP (to)) 1233 if (NILP (to))
1238 { 1234 to_char = size;
1239 to_char = size;
1240 to_byte = size_byte;
1241 }
1242 else 1235 else
1243 { 1236 {
1244 CHECK_NUMBER (to); 1237 CHECK_NUMBER (to);
1245
1246 to_char = XINT (to); 1238 to_char = XINT (to);
1247 if (to_char < 0) 1239 if (to_char < 0)
1248 to_char += size; 1240 to_char += size;
1249
1250 to_byte = string_char_to_byte (string, to_char);
1251 } 1241 }
1252 1242
1253 if (!(0 <= from_char && from_char <= to_char && to_char <= size)) 1243 if (!(0 <= from_char && from_char <= to_char && to_char <= size))
1254 args_out_of_range_3 (string, make_number (from_char), 1244 args_out_of_range_3 (string, make_number (from_char),
1255 make_number (to_char)); 1245 make_number (to_char));
1256 1246
1247 from_byte = NILP (from) ? 0 : string_char_to_byte (string, from_char);
1248 to_byte =
1249 NILP (to) ? SBYTES (string) : string_char_to_byte (string, to_char);
1257 return make_specified_string (SSDATA (string) + from_byte, 1250 return make_specified_string (SSDATA (string) + from_byte,
1258 to_char - from_char, to_byte - from_byte, 1251 to_char - from_char, to_byte - from_byte,
1259 STRING_MULTIBYTE (string)); 1252 STRING_MULTIBYTE (string));
@@ -1263,11 +1256,11 @@ With one argument, just copy STRING without its properties. */)
1263 both in characters and in bytes. */ 1256 both in characters and in bytes. */
1264 1257
1265Lisp_Object 1258Lisp_Object
1266substring_both (Lisp_Object string, EMACS_INT from, EMACS_INT from_byte, 1259substring_both (Lisp_Object string, ptrdiff_t from, ptrdiff_t from_byte,
1267 EMACS_INT to, EMACS_INT to_byte) 1260 ptrdiff_t to, ptrdiff_t to_byte)
1268{ 1261{
1269 Lisp_Object res; 1262 Lisp_Object res;
1270 EMACS_INT size; 1263 ptrdiff_t size;
1271 1264
1272 CHECK_VECTOR_OR_STRING (string); 1265 CHECK_VECTOR_OR_STRING (string);
1273 1266
@@ -1601,7 +1594,7 @@ to be sure of changing the value of `foo'. */)
1601{ 1594{
1602 if (VECTORP (seq)) 1595 if (VECTORP (seq))
1603 { 1596 {
1604 EMACS_INT i, n; 1597 ptrdiff_t i, n;
1605 1598
1606 for (i = n = 0; i < ASIZE (seq); ++i) 1599 for (i = n = 0; i < ASIZE (seq); ++i)
1607 if (NILP (Fequal (AREF (seq, i), elt))) 1600 if (NILP (Fequal (AREF (seq, i), elt)))
@@ -1620,7 +1613,7 @@ to be sure of changing the value of `foo'. */)
1620 } 1613 }
1621 else if (STRINGP (seq)) 1614 else if (STRINGP (seq))
1622 { 1615 {
1623 EMACS_INT i, ibyte, nchars, nbytes, cbytes; 1616 ptrdiff_t i, ibyte, nchars, nbytes, cbytes;
1624 int c; 1617 int c;
1625 1618
1626 for (i = nchars = nbytes = ibyte = 0; 1619 for (i = nchars = nbytes = ibyte = 0;
@@ -1672,7 +1665,7 @@ to be sure of changing the value of `foo'. */)
1672 { 1665 {
1673 unsigned char *from = SDATA (seq) + ibyte; 1666 unsigned char *from = SDATA (seq) + ibyte;
1674 unsigned char *to = SDATA (tem) + nbytes; 1667 unsigned char *to = SDATA (tem) + nbytes;
1675 EMACS_INT n; 1668 ptrdiff_t n;
1676 1669
1677 ++nchars; 1670 ++nchars;
1678 nbytes += cbytes; 1671 nbytes += cbytes;
@@ -2079,7 +2072,7 @@ internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int
2079 case Lisp_Vectorlike: 2072 case Lisp_Vectorlike:
2080 { 2073 {
2081 register int i; 2074 register int i;
2082 EMACS_INT size = ASIZE (o1); 2075 ptrdiff_t size = ASIZE (o1);
2083 /* Pseudovectors have the type encoded in the size field, so this test 2076 /* Pseudovectors have the type encoded in the size field, so this test
2084 actually checks that the objects have the same type as well as the 2077 actually checks that the objects have the same type as well as the
2085 same size. */ 2078 same size. */
@@ -2146,7 +2139,7 @@ DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0,
2146ARRAY is a vector, string, char-table, or bool-vector. */) 2139ARRAY is a vector, string, char-table, or bool-vector. */)
2147 (Lisp_Object array, Lisp_Object item) 2140 (Lisp_Object array, Lisp_Object item)
2148{ 2141{
2149 register EMACS_INT size, idx; 2142 register ptrdiff_t size, idx;
2150 2143
2151 if (VECTORP (array)) 2144 if (VECTORP (array))
2152 { 2145 {
@@ -2174,7 +2167,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2174 { 2167 {
2175 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2168 unsigned char str[MAX_MULTIBYTE_LENGTH];
2176 int len = CHAR_STRING (charval, str); 2169 int len = CHAR_STRING (charval, str);
2177 EMACS_INT size_byte = SBYTES (array); 2170 ptrdiff_t size_byte = SBYTES (array);
2178 2171
2179 if (INT_MULTIPLY_OVERFLOW (SCHARS (array), len) 2172 if (INT_MULTIPLY_OVERFLOW (SCHARS (array), len)
2180 || SCHARS (array) * len != size_byte) 2173 || SCHARS (array) * len != size_byte)
@@ -2189,18 +2182,16 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2189 else if (BOOL_VECTOR_P (array)) 2182 else if (BOOL_VECTOR_P (array))
2190 { 2183 {
2191 register unsigned char *p = XBOOL_VECTOR (array)->data; 2184 register unsigned char *p = XBOOL_VECTOR (array)->data;
2192 EMACS_INT size_in_chars; 2185 size =
2193 size = XBOOL_VECTOR (array)->size; 2186 ((XBOOL_VECTOR (array)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
2194 size_in_chars 2187 / BOOL_VECTOR_BITS_PER_CHAR);
2195 = ((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
2196 / BOOL_VECTOR_BITS_PER_CHAR);
2197 2188
2198 if (size_in_chars) 2189 if (size)
2199 { 2190 {
2200 memset (p, ! NILP (item) ? -1 : 0, size_in_chars); 2191 memset (p, ! NILP (item) ? -1 : 0, size);
2201 2192
2202 /* Clear any extraneous bits in the last byte. */ 2193 /* Clear any extraneous bits in the last byte. */
2203 p[size_in_chars - 1] &= (1 << (size % BOOL_VECTOR_BITS_PER_CHAR)) - 1; 2194 p[size - 1] &= (1 << (size % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
2204 } 2195 }
2205 } 2196 }
2206 else 2197 else
@@ -2214,7 +2205,7 @@ DEFUN ("clear-string", Fclear_string, Sclear_string,
2214This makes STRING unibyte and may change its length. */) 2205This makes STRING unibyte and may change its length. */)
2215 (Lisp_Object string) 2206 (Lisp_Object string)
2216{ 2207{
2217 EMACS_INT len; 2208 ptrdiff_t len;
2218 CHECK_STRING (string); 2209 CHECK_STRING (string);
2219 len = SBYTES (string); 2210 len = SBYTES (string);
2220 memset (SDATA (string), 0, len); 2211 memset (SDATA (string), 0, len);
@@ -2324,12 +2315,12 @@ mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
2324 } 2315 }
2325 else if (STRINGP (seq)) 2316 else if (STRINGP (seq))
2326 { 2317 {
2327 EMACS_INT i_byte; 2318 ptrdiff_t i_byte;
2328 2319
2329 for (i = 0, i_byte = 0; i < leni;) 2320 for (i = 0, i_byte = 0; i < leni;)
2330 { 2321 {
2331 int c; 2322 int c;
2332 EMACS_INT i_before = i; 2323 ptrdiff_t i_before = i;
2333 2324
2334 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte); 2325 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte);
2335 XSETFASTINT (dummy, c); 2326 XSETFASTINT (dummy, c);
@@ -2362,7 +2353,8 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2362{ 2353{
2363 Lisp_Object len; 2354 Lisp_Object len;
2364 register EMACS_INT leni; 2355 register EMACS_INT leni;
2365 ptrdiff_t i, nargs; 2356 EMACS_INT nargs;
2357 ptrdiff_t i;
2366 register Lisp_Object *args; 2358 register Lisp_Object *args;
2367 struct gcpro gcpro1; 2359 struct gcpro gcpro1;
2368 Lisp_Object ret; 2360 Lisp_Object ret;
@@ -2649,7 +2641,7 @@ The normal messages at start and end of loading FILENAME are suppressed. */)
2649 2641
2650 if (NILP (tem)) 2642 if (NILP (tem))
2651 { 2643 {
2652 int count = SPECPDL_INDEX (); 2644 ptrdiff_t count = SPECPDL_INDEX ();
2653 int nesting = 0; 2645 int nesting = 0;
2654 2646
2655 /* This is to make sure that loadup.el gives a clear picture 2647 /* This is to make sure that loadup.el gives a clear picture
@@ -2952,9 +2944,9 @@ static const short base64_char_to_value[128] =
2952 base64 characters. */ 2944 base64 characters. */
2953 2945
2954 2946
2955static EMACS_INT base64_encode_1 (const char *, char *, EMACS_INT, int, int); 2947static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, int, int);
2956static EMACS_INT base64_decode_1 (const char *, char *, EMACS_INT, int, 2948static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, int,
2957 EMACS_INT *); 2949 ptrdiff_t *);
2958 2950
2959DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2951DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
2960 2, 3, "r", 2952 2, 3, "r",
@@ -2965,9 +2957,9 @@ into shorter lines. */)
2965 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break) 2957 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break)
2966{ 2958{
2967 char *encoded; 2959 char *encoded;
2968 EMACS_INT allength, length; 2960 ptrdiff_t allength, length;
2969 EMACS_INT ibeg, iend, encoded_length; 2961 ptrdiff_t ibeg, iend, encoded_length;
2970 EMACS_INT old_pos = PT; 2962 ptrdiff_t old_pos = PT;
2971 USE_SAFE_ALLOCA; 2963 USE_SAFE_ALLOCA;
2972 2964
2973 validate_region (&beg, &end); 2965 validate_region (&beg, &end);
@@ -3023,7 +3015,7 @@ Optional second argument NO-LINE-BREAK means do not break long lines
3023into shorter lines. */) 3015into shorter lines. */)
3024 (Lisp_Object string, Lisp_Object no_line_break) 3016 (Lisp_Object string, Lisp_Object no_line_break)
3025{ 3017{
3026 EMACS_INT allength, length, encoded_length; 3018 ptrdiff_t allength, length, encoded_length;
3027 char *encoded; 3019 char *encoded;
3028 Lisp_Object encoded_string; 3020 Lisp_Object encoded_string;
3029 USE_SAFE_ALLOCA; 3021 USE_SAFE_ALLOCA;
@@ -3059,12 +3051,12 @@ into shorter lines. */)
3059 return encoded_string; 3051 return encoded_string;
3060} 3052}
3061 3053
3062static EMACS_INT 3054static ptrdiff_t
3063base64_encode_1 (const char *from, char *to, EMACS_INT length, 3055base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3064 int line_break, int multibyte) 3056 int line_break, int multibyte)
3065{ 3057{
3066 int counter = 0; 3058 int counter = 0;
3067 EMACS_INT i = 0; 3059 ptrdiff_t i = 0;
3068 char *e = to; 3060 char *e = to;
3069 int c; 3061 int c;
3070 unsigned int value; 3062 unsigned int value;
@@ -3163,11 +3155,11 @@ Return the length of the decoded text.
3163If the region can't be decoded, signal an error and don't modify the buffer. */) 3155If the region can't be decoded, signal an error and don't modify the buffer. */)
3164 (Lisp_Object beg, Lisp_Object end) 3156 (Lisp_Object beg, Lisp_Object end)
3165{ 3157{
3166 EMACS_INT ibeg, iend, length, allength; 3158 ptrdiff_t ibeg, iend, length, allength;
3167 char *decoded; 3159 char *decoded;
3168 EMACS_INT old_pos = PT; 3160 ptrdiff_t old_pos = PT;
3169 EMACS_INT decoded_length; 3161 ptrdiff_t decoded_length;
3170 EMACS_INT inserted_chars; 3162 ptrdiff_t inserted_chars;
3171 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3163 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3172 USE_SAFE_ALLOCA; 3164 USE_SAFE_ALLOCA;
3173 3165
@@ -3225,7 +3217,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3225 (Lisp_Object string) 3217 (Lisp_Object string)
3226{ 3218{
3227 char *decoded; 3219 char *decoded;
3228 EMACS_INT length, decoded_length; 3220 ptrdiff_t length, decoded_length;
3229 Lisp_Object decoded_string; 3221 Lisp_Object decoded_string;
3230 USE_SAFE_ALLOCA; 3222 USE_SAFE_ALLOCA;
3231 3223
@@ -3257,15 +3249,15 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3257 form. If NCHARS_RETRUN is not NULL, store the number of produced 3249 form. If NCHARS_RETRUN is not NULL, store the number of produced
3258 characters in *NCHARS_RETURN. */ 3250 characters in *NCHARS_RETURN. */
3259 3251
3260static EMACS_INT 3252static ptrdiff_t
3261base64_decode_1 (const char *from, char *to, EMACS_INT length, 3253base64_decode_1 (const char *from, char *to, ptrdiff_t length,
3262 int multibyte, EMACS_INT *nchars_return) 3254 int multibyte, ptrdiff_t *nchars_return)
3263{ 3255{
3264 EMACS_INT i = 0; /* Used inside READ_QUADRUPLET_BYTE */ 3256 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3265 char *e = to; 3257 char *e = to;
3266 unsigned char c; 3258 unsigned char c;
3267 unsigned long value; 3259 unsigned long value;
3268 EMACS_INT nchars = 0; 3260 ptrdiff_t nchars = 0;
3269 3261
3270 while (1) 3262 while (1)
3271 { 3263 {
@@ -3432,23 +3424,31 @@ get_key_arg (Lisp_Object key, ptrdiff_t nargs, Lisp_Object *args, char *used)
3432 3424
3433 3425
3434/* Return a Lisp vector which has the same contents as VEC but has 3426/* Return a Lisp vector which has the same contents as VEC but has
3435 size NEW_SIZE, NEW_SIZE >= VEC->size. Entries in the resulting 3427 at least INCR_MIN more entries, where INCR_MIN is positive.
3436 vector that are not copied from VEC are set to INIT. */ 3428 If NITEMS_MAX is not -1, do not grow the vector to be any larger
3429 than NITEMS_MAX. Entries in the resulting
3430 vector that are not copied from VEC are set to nil. */
3437 3431
3438Lisp_Object 3432Lisp_Object
3439larger_vector (Lisp_Object vec, EMACS_INT new_size, Lisp_Object init) 3433larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t size_max)
3440{ 3434{
3441 struct Lisp_Vector *v; 3435 struct Lisp_Vector *v;
3442 EMACS_INT i, old_size; 3436 ptrdiff_t i, incr, incr_max, old_size, new_size;
3443 3437 ptrdiff_t C_language_max = min (PTRDIFF_MAX, SIZE_MAX) / sizeof *v->contents;
3438 ptrdiff_t n_max = (0 <= size_max && size_max < C_language_max
3439 ? size_max : C_language_max);
3444 xassert (VECTORP (vec)); 3440 xassert (VECTORP (vec));
3441 xassert (0 < incr_min && -1 <= size_max);
3445 old_size = ASIZE (vec); 3442 old_size = ASIZE (vec);
3446 xassert (new_size >= old_size); 3443 incr_max = n_max - old_size;
3447 3444 incr = max (incr_min, min (old_size >> 1, incr_max));
3445 if (incr_max < incr)
3446 memory_full (SIZE_MAX);
3447 new_size = old_size + incr;
3448 v = allocate_vector (new_size); 3448 v = allocate_vector (new_size);
3449 memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents); 3449 memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents);
3450 for (i = old_size; i < new_size; ++i) 3450 for (i = old_size; i < new_size; ++i)
3451 v->contents[i] = init; 3451 v->contents[i] = Qnil;
3452 XSETVECTOR (vec, v); 3452 XSETVECTOR (vec, v);
3453 return vec; 3453 return vec;
3454} 3454}
@@ -3569,6 +3569,10 @@ hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key)
3569 return XUINT (hash); 3569 return XUINT (hash);
3570} 3570}
3571 3571
3572/* An upper bound on the size of a hash table index. It must fit in
3573 ptrdiff_t and be a valid Emacs fixnum. */
3574#define INDEX_SIZE_BOUND \
3575 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX / sizeof (Lisp_Object)))
3572 3576
3573/* Create and initialize a new hash table. 3577/* Create and initialize a new hash table.
3574 3578
@@ -3599,7 +3603,8 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size,
3599{ 3603{
3600 struct Lisp_Hash_Table *h; 3604 struct Lisp_Hash_Table *h;
3601 Lisp_Object table; 3605 Lisp_Object table;
3602 EMACS_INT index_size, i, sz; 3606 EMACS_INT index_size, sz;
3607 ptrdiff_t i;
3603 double index_float; 3608 double index_float;
3604 3609
3605 /* Preconditions. */ 3610 /* Preconditions. */
@@ -3616,10 +3621,10 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size,
3616 3621
3617 sz = XFASTINT (size); 3622 sz = XFASTINT (size);
3618 index_float = sz / XFLOAT_DATA (rehash_threshold); 3623 index_float = sz / XFLOAT_DATA (rehash_threshold);
3619 index_size = (index_float < MOST_POSITIVE_FIXNUM + 1 3624 index_size = (index_float < INDEX_SIZE_BOUND + 1
3620 ? next_almost_prime (index_float) 3625 ? next_almost_prime (index_float)
3621 : MOST_POSITIVE_FIXNUM + 1); 3626 : INDEX_SIZE_BOUND + 1);
3622 if (MOST_POSITIVE_FIXNUM < max (index_size, 2 * sz)) 3627 if (INDEX_SIZE_BOUND < max (index_size, 2 * sz))
3623 error ("Hash table too large"); 3628 error ("Hash table too large");
3624 3629
3625 /* Allocate a table and initialize it. */ 3630 /* Allocate a table and initialize it. */
@@ -3720,9 +3725,9 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3720{ 3725{
3721 if (NILP (h->next_free)) 3726 if (NILP (h->next_free))
3722 { 3727 {
3723 EMACS_INT old_size = HASH_TABLE_SIZE (h); 3728 ptrdiff_t old_size = HASH_TABLE_SIZE (h);
3724 EMACS_INT i, new_size, index_size; 3729 EMACS_INT new_size, index_size, nsize;
3725 EMACS_INT nsize; 3730 ptrdiff_t i;
3726 double index_float; 3731 double index_float;
3727 3732
3728 if (INTEGERP (h->rehash_size)) 3733 if (INTEGERP (h->rehash_size))
@@ -3730,26 +3735,27 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3730 else 3735 else
3731 { 3736 {
3732 double float_new_size = old_size * XFLOAT_DATA (h->rehash_size); 3737 double float_new_size = old_size * XFLOAT_DATA (h->rehash_size);
3733 if (float_new_size < MOST_POSITIVE_FIXNUM + 1) 3738 if (float_new_size < INDEX_SIZE_BOUND + 1)
3734 { 3739 {
3735 new_size = float_new_size; 3740 new_size = float_new_size;
3736 if (new_size <= old_size) 3741 if (new_size <= old_size)
3737 new_size = old_size + 1; 3742 new_size = old_size + 1;
3738 } 3743 }
3739 else 3744 else
3740 new_size = MOST_POSITIVE_FIXNUM + 1; 3745 new_size = INDEX_SIZE_BOUND + 1;
3741 } 3746 }
3742 index_float = new_size / XFLOAT_DATA (h->rehash_threshold); 3747 index_float = new_size / XFLOAT_DATA (h->rehash_threshold);
3743 index_size = (index_float < MOST_POSITIVE_FIXNUM + 1 3748 index_size = (index_float < INDEX_SIZE_BOUND + 1
3744 ? next_almost_prime (index_float) 3749 ? next_almost_prime (index_float)
3745 : MOST_POSITIVE_FIXNUM + 1); 3750 : INDEX_SIZE_BOUND + 1);
3746 nsize = max (index_size, 2 * new_size); 3751 nsize = max (index_size, 2 * new_size);
3747 if (nsize > MOST_POSITIVE_FIXNUM) 3752 if (INDEX_SIZE_BOUND < nsize)
3748 error ("Hash table too large to resize"); 3753 error ("Hash table too large to resize");
3749 3754
3750 h->key_and_value = larger_vector (h->key_and_value, 2 * new_size, Qnil); 3755 h->key_and_value = larger_vector (h->key_and_value,
3751 h->next = larger_vector (h->next, new_size, Qnil); 3756 2 * (new_size - old_size), -1);
3752 h->hash = larger_vector (h->hash, new_size, Qnil); 3757 h->next = larger_vector (h->next, new_size - old_size, -1);
3758 h->hash = larger_vector (h->hash, new_size - old_size, -1);
3753 h->index = Fmake_vector (make_number (index_size), Qnil); 3759 h->index = Fmake_vector (make_number (index_size), Qnil);
3754 3760
3755 /* Update the free list. Do it so that new entries are added at 3761 /* Update the free list. Do it so that new entries are added at
@@ -3777,7 +3783,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3777 if (!NILP (HASH_HASH (h, i))) 3783 if (!NILP (HASH_HASH (h, i)))
3778 { 3784 {
3779 EMACS_UINT hash_code = XUINT (HASH_HASH (h, i)); 3785 EMACS_UINT hash_code = XUINT (HASH_HASH (h, i));
3780 EMACS_INT start_of_bucket = hash_code % ASIZE (h->index); 3786 ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index);
3781 HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); 3787 HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
3782 HASH_INDEX (h, start_of_bucket) = make_number (i); 3788 HASH_INDEX (h, start_of_bucket) = make_number (i);
3783 } 3789 }
@@ -3806,7 +3812,7 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
3806 /* We need not gcpro idx since it's either an integer or nil. */ 3812 /* We need not gcpro idx since it's either an integer or nil. */
3807 while (!NILP (idx)) 3813 while (!NILP (idx))
3808 { 3814 {
3809 EMACS_INT i = XFASTINT (idx); 3815 ptrdiff_t i = XFASTINT (idx);
3810 if (EQ (key, HASH_KEY (h, i)) 3816 if (EQ (key, HASH_KEY (h, i))
3811 || (h->cmpfn 3817 || (h->cmpfn
3812 && h->cmpfn (h, key, hash_code, 3818 && h->cmpfn (h, key, hash_code,
@@ -3858,7 +3864,7 @@ static void
3858hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key) 3864hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key)
3859{ 3865{
3860 EMACS_UINT hash_code; 3866 EMACS_UINT hash_code;
3861 EMACS_INT start_of_bucket; 3867 ptrdiff_t start_of_bucket;
3862 Lisp_Object idx, prev; 3868 Lisp_Object idx, prev;
3863 3869
3864 hash_code = h->hashfn (h, key); 3870 hash_code = h->hashfn (h, key);
@@ -3869,7 +3875,7 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key)
3869 /* We need not gcpro idx, prev since they're either integers or nil. */ 3875 /* We need not gcpro idx, prev since they're either integers or nil. */
3870 while (!NILP (idx)) 3876 while (!NILP (idx))
3871 { 3877 {
3872 EMACS_INT i = XFASTINT (idx); 3878 ptrdiff_t i = XFASTINT (idx);
3873 3879
3874 if (EQ (key, HASH_KEY (h, i)) 3880 if (EQ (key, HASH_KEY (h, i))
3875 || (h->cmpfn 3881 || (h->cmpfn
@@ -3907,7 +3913,7 @@ hash_clear (struct Lisp_Hash_Table *h)
3907{ 3913{
3908 if (h->count > 0) 3914 if (h->count > 0)
3909 { 3915 {
3910 EMACS_INT i, size = HASH_TABLE_SIZE (h); 3916 ptrdiff_t i, size = HASH_TABLE_SIZE (h);
3911 3917
3912 for (i = 0; i < size; ++i) 3918 for (i = 0; i < size; ++i)
3913 { 3919 {
@@ -3945,7 +3951,7 @@ init_weak_hash_tables (void)
3945static int 3951static int
3946sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) 3952sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3947{ 3953{
3948 EMACS_INT bucket, n; 3954 ptrdiff_t bucket, n;
3949 int marked; 3955 int marked;
3950 3956
3951 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG; 3957 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG;
@@ -3960,7 +3966,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3960 prev = Qnil; 3966 prev = Qnil;
3961 for (idx = HASH_INDEX (h, bucket); !NILP (idx); idx = next) 3967 for (idx = HASH_INDEX (h, bucket); !NILP (idx); idx = next)
3962 { 3968 {
3963 EMACS_INT i = XFASTINT (idx); 3969 ptrdiff_t i = XFASTINT (idx);
3964 int key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i)); 3970 int key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
3965 int value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i)); 3971 int value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
3966 int remove_p; 3972 int remove_p;
@@ -4526,7 +4532,7 @@ FUNCTION is called with two arguments, KEY and VALUE. */)
4526{ 4532{
4527 struct Lisp_Hash_Table *h = check_hash_table (table); 4533 struct Lisp_Hash_Table *h = check_hash_table (table);
4528 Lisp_Object args[3]; 4534 Lisp_Object args[3];
4529 EMACS_INT i; 4535 ptrdiff_t i;
4530 4536
4531 for (i = 0; i < HASH_TABLE_SIZE (h); ++i) 4537 for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
4532 if (!NILP (HASH_HASH (h, i))) 4538 if (!NILP (HASH_HASH (h, i)))
@@ -4575,10 +4581,9 @@ static Lisp_Object
4575secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object noerror, Lisp_Object binary) 4581secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object noerror, Lisp_Object binary)
4576{ 4582{
4577 int i; 4583 int i;
4578 EMACS_INT size; 4584 ptrdiff_t size;
4579 EMACS_INT size_byte = 0;
4580 EMACS_INT start_char = 0, end_char = 0; 4585 EMACS_INT start_char = 0, end_char = 0;
4581 EMACS_INT start_byte = 0, end_byte = 0; 4586 ptrdiff_t start_byte, end_byte;
4582 register EMACS_INT b, e; 4587 register EMACS_INT b, e;
4583 register struct buffer *bp; 4588 register struct buffer *bp;
4584 EMACS_INT temp; 4589 EMACS_INT temp;
@@ -4615,7 +4620,6 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4615 object = code_convert_string (object, coding_system, Qnil, 1, 0, 1); 4620 object = code_convert_string (object, coding_system, Qnil, 1, 0, 1);
4616 4621
4617 size = SCHARS (object); 4622 size = SCHARS (object);
4618 size_byte = SBYTES (object);
4619 4623
4620 if (!NILP (start)) 4624 if (!NILP (start))
4621 { 4625 {
@@ -4625,15 +4629,10 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4625 4629
4626 if (start_char < 0) 4630 if (start_char < 0)
4627 start_char += size; 4631 start_char += size;
4628
4629 start_byte = string_char_to_byte (object, start_char);
4630 } 4632 }
4631 4633
4632 if (NILP (end)) 4634 if (NILP (end))
4633 { 4635 end_char = size;
4634 end_char = size;
4635 end_byte = size_byte;
4636 }
4637 else 4636 else
4638 { 4637 {
4639 CHECK_NUMBER (end); 4638 CHECK_NUMBER (end);
@@ -4642,13 +4641,15 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4642 4641
4643 if (end_char < 0) 4642 if (end_char < 0)
4644 end_char += size; 4643 end_char += size;
4645
4646 end_byte = string_char_to_byte (object, end_char);
4647 } 4644 }
4648 4645
4649 if (!(0 <= start_char && start_char <= end_char && end_char <= size)) 4646 if (!(0 <= start_char && start_char <= end_char && end_char <= size))
4650 args_out_of_range_3 (object, make_number (start_char), 4647 args_out_of_range_3 (object, make_number (start_char),
4651 make_number (end_char)); 4648 make_number (end_char));
4649
4650 start_byte = NILP (start) ? 0 : string_char_to_byte (object, start_char);
4651 end_byte =
4652 NILP (end) ? SBYTES (object) : string_char_to_byte (object, end_char);
4652 } 4653 }
4653 else 4654 else
4654 { 4655 {
@@ -4755,6 +4756,8 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4755 4756
4756 if (STRING_MULTIBYTE (object)) 4757 if (STRING_MULTIBYTE (object))
4757 object = code_convert_string (object, coding_system, Qnil, 1, 0, 0); 4758 object = code_convert_string (object, coding_system, Qnil, 1, 0, 0);
4759 start_byte = 0;
4760 end_byte = SBYTES (object);
4758 } 4761 }
4759 4762
4760 if (EQ (algorithm, Qmd5)) 4763 if (EQ (algorithm, Qmd5))
@@ -4795,7 +4798,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4795 digest = make_uninit_string (digest_size * 2); 4798 digest = make_uninit_string (digest_size * 2);
4796 4799
4797 hash_func (SSDATA (object) + start_byte, 4800 hash_func (SSDATA (object) + start_byte,
4798 SBYTES (object) - (size_byte - end_byte), 4801 end_byte - start_byte,
4799 SSDATA (digest)); 4802 SSDATA (digest));
4800 4803
4801 if (NILP (binary)) 4804 if (NILP (binary))