From b68864e5b9b695570d35dd7c41d5d010ba7cc87d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 6 Feb 2011 11:44:36 -0800 Subject: * insdel.c: conform to C89 pointer rules --- src/coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 3a3ba11ee9d..a9f16de56f3 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7880,7 +7880,7 @@ encode_coding_object (struct coding_system *coding, else if (BUFFERP (src_object)) insert_from_buffer (XBUFFER (src_object), from, chars, 0); else - insert_1_both (coding->source + from, chars, bytes, 0, 0, 0); + insert_1_both ((char *) coding->source + from, chars, bytes, 0, 0, 0); if (EQ (src_object, dst_object)) { -- cgit v1.2.1 From 5d8ea1203d1e659bc77d953784a85a6e7da0ce95 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 14 Feb 2011 08:39:19 -0700 Subject: Hide implementation of `struct buffer' * composite.c (fill_gstring_header) (composition_compute_stop_pos, composition_adjust_point) (Ffind_composition_internal): Use B_. * intervals.c (set_point_both, get_local_map): Use B_. * callproc.c (Fcall_process, Fcall_process_region): Use B_. * process.c (get_process, list_processes_1, Fstart_process) (Fmake_serial_process, Fmake_network_process) (read_process_output, send_process, exec_sentinel) (status_notify, setup_process_coding_systems): Use B_. * bytecode.c (Fbyte_code): Use B_. * syntax.c (update_syntax_table, dec_bytepos, Fsyntax_table) (Fset_syntax_table, Fmodify_syntax_entry, skip_chars) (skip_syntaxes, scan_lists): Use B_. * lread.c (readchar, unreadchar, openp, readevalloop) (Feval_buffer, Feval_region): Use B_. * print.c (printchar, strout, print_string, PRINTDECLARE) (PRINTPREPARE, PRINTFINISH, temp_output_buffer_setup) (print_object): Use B_. * font.c (font_at): Use B_. * fns.c (Fbase64_encode_region, Fbase64_decode_region, Fmd5): Use B_. * callint.c (check_mark, Fcall_interactively): Use B_. * editfns.c (region_limit, Fmark_marker, save_excursion_save) (save_excursion_restore, Fprevious_char, Fchar_before) (general_insert_function, Finsert_char, Finsert_byte) (make_buffer_string_both, Finsert_buffer_substring) (Fcompare_buffer_substrings, subst_char_in_region_unwind) (subst_char_in_region_unwind_1, Fsubst_char_in_region) (Ftranslate_region_internal, save_restriction_restore) (Fchar_equal): Use B_. * data.c (swap_in_symval_forwarding, set_internal) (Fmake_local_variable, Fkill_local_variable, Flocal_variable_p): Use B_. * undo.c (record_point, record_insert, record_delete) (record_marker_adjustment, record_first_change) (record_property_change, Fundo_boundary, truncate_undo_list) (Fprimitive_undo): Use B_. * search.c (compile_pattern_1, compile_pattern, looking_at_1) (string_match_1, fast_looking_at, newline_cache_on_off) (search_command, search_buffer, simple_search, boyer_moore) (Freplace_match): Use B_. * indent.c (buffer_display_table, recompute_width_table) (width_run_cache_on_off, current_column, scan_for_column) (Findent_to, position_indentation, compute_motion, vmotion): Use B_. * casefiddle.c (casify_object, casify_region): Use B_. * casetab.c (Fcurrent_case_table, set_case_table): Use B_. * cmds.c (Fself_insert_command, internal_self_insert): Use B_. * fileio.c (Fexpand_file_name, Ffile_directory_p) (Ffile_regular_p, Ffile_selinux_context) (Fset_file_selinux_context, Ffile_modes, Fset_file_modes) (Fset_file_times, Ffile_newer_than_file_p, decide_coding_unwind) (Finsert_file_contents, choose_write_coding_system) (Fwrite_region, build_annotations, Fverify_visited_file_modtime) (Fset_visited_file_modtime, auto_save_error, auto_save_1) (Fdo_auto_save, Fset_buffer_auto_saved): Use B_. * minibuf.c (read_minibuf, get_minibuffer, Fread_buffer): Use B_. * marker.c (Fmarker_buffer, Fset_marker, set_marker_restricted) (set_marker_both, set_marker_restricted_both, unchain_marker): Use B_. * insdel.c (check_markers, insert_char, insert_1_both) (insert_from_string_1, insert_from_gap, insert_from_buffer_1) (adjust_after_replace, replace_range, del_range_2) (modify_region, prepare_to_modify_buffer) (Fcombine_after_change_execute): Use B_. * filelock.c (unlock_all_files, Flock_buffer, Funlock_buffer) (unlock_buffer): Use B_. * keymap.c (Flocal_key_binding, Fuse_local_map) (Fcurrent_local_map, push_key_description) (Fdescribe_buffer_bindings): Use B_. * keyboard.c (command_loop_1, read_char_minibuf_menu_prompt) (read_key_sequence): Use B_. * fringe.c (get_logical_cursor_bitmap) (get_logical_fringe_bitmap, update_window_fringes): Use B_. * xfns.c (x_create_tip_frame, Fx_show_tip): Use B_. * xfaces.c (compute_char_face): Use B_. * character.c (chars_in_text, Fget_byte): Use B_. * category.c (check_category_table, Fcategory_table) (Fset_category_table, char_category_set): Use B_. * coding.c (decode_coding, encode_coding) (make_conversion_work_buffer, decode_coding_gap) (decode_coding_object, encode_coding_object) (Fdetect_coding_region, Ffind_coding_systems_region_internal) (Funencodable_char_position, Fcheck_coding_systems_region): Use B_. * charset.c (Ffind_charset_region): Use B_. * window.c (window_display_table, unshow_buffer, window_loop) (window_min_size_2, set_window_buffer, Fset_window_buffer) (select_window, Fforce_window_update, temp_output_buffer_show) (Fset_window_configuration, save_window_save): Use B_. * xdisp.c (pos_visible_p, init_iterator, reseat_1) (message_dolog, update_echo_area, ensure_echo_area_buffers) (with_echo_area_buffer, setup_echo_area_for_printing) (set_message_1, update_menu_bar, update_tool_bar) (text_outside_line_unchanged_p, redisplay_internal) (try_scrolling, try_cursor_movement, redisplay_window) (try_window_reusing_current_matrix, row_containing_pos) (try_window_id, get_overlay_arrow_glyph_row, display_line) (Fcurrent_bidi_paragraph_direction, display_mode_lines) (decode_mode_spec_coding, decode_mode_spec, display_count_lines) (get_window_cursor_type, note_mouse_highlight): Use B_. * frame.c (make_frame_visible_1): Use B_. * dispnew.c (Fframe_or_buffer_changed_p): Use B_. * dispextern.h (WINDOW_WANTS_HEADER_LINE_P) (WINDOW_WANTS_MODELINE_P): Use B_. * syntax.h (Vstandard_syntax_table): Update. (CURRENT_SYNTAX_TABLE, SETUP_BUFFER_SYNTAX_TABLE): Use B_. * intervals.h (TEXT_PROP_MEANS_INVISIBLE): Update. (TEXT_PROP_MEANS_INVISIBLE): Use B_. * character.h (FETCH_CHAR_ADVANCE): Update. (INC_BOTH, ASCII_CHAR_WIDTH, DEC_BOTH): Use B_. * category.h (Vstandard_category_table): Update. * lisp.h (DEFVAR_BUFFER_DEFAULTS): Update for change to field names. (DOWNCASE_TABLE, UPCASE_TABLE): Use B_. * buffer.c (swapfield_): New macro. (Fbuffer_swap_text): Use swapfield_ where appropriate. (Fbuffer_live_p, Fget_file_buffer, get_truename_buffer) (Fget_buffer_create, clone_per_buffer_values) (Fmake_indirect_buffer, reset_buffer) (reset_buffer_local_variables, Fbuffer_name, Fbuffer_file_name) (Fbuffer_local_value, buffer_lisp_local_variables) (Fset_buffer_modified_p, Frestore_buffer_modified_p) (Frename_buffer, Fother_buffer, Fbuffer_enable_undo) (Fkill_buffer, Fset_buffer_major_mode, set_buffer_internal_1) (set_buffer_temp, Fset_buffer, set_buffer_if_live) (Fbarf_if_buffer_read_only, Fbury_buffer, Ferase_buffer) (Fbuffer_swap_text, Fset_buffer_multibyte) (swap_out_buffer_local_variables, record_overlay_string) (overlay_strings, init_buffer_once, init_buffer, syms_of_buffer): Use B_. * buffer.h (struct buffer): Rename all Lisp_Object fields. (BUFFER_INTERNAL_FIELD, B_): New macro. (FETCH_CHAR, FETCH_CHAR_AS_MULTIBYTE): Use B_. --- src/coding.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index a9f16de56f3..899cca6d5aa 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7038,8 +7038,8 @@ decode_coding (struct coding_system *coding) set_buffer_internal (XBUFFER (coding->dst_object)); if (GPT != PT) move_gap_both (PT, PT_BYTE); - undo_list = current_buffer->undo_list; - current_buffer->undo_list = Qt; + undo_list = B_ (current_buffer, undo_list); + B_ (current_buffer, undo_list) = Qt; } coding->consumed = coding->consumed_char = 0; @@ -7136,7 +7136,7 @@ decode_coding (struct coding_system *coding) decode_eol (coding); if (BUFFERP (coding->dst_object)) { - current_buffer->undo_list = undo_list; + B_ (current_buffer, undo_list) = undo_list; record_insert (coding->dst_pos, coding->produced_char); } return coding->result; @@ -7433,7 +7433,7 @@ encode_coding (struct coding_system *coding) { set_buffer_internal (XBUFFER (coding->dst_object)); coding->dst_multibyte - = ! NILP (current_buffer->enable_multibyte_characters); + = ! NILP (B_ (current_buffer, enable_multibyte_characters)); } coding->consumed = coding->consumed_char = 0; @@ -7504,8 +7504,8 @@ make_conversion_work_buffer (int multibyte) doesn't compile new regexps. */ Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); Ferase_buffer (); - current_buffer->undo_list = Qt; - current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil; + B_ (current_buffer, undo_list) = Qt; + B_ (current_buffer, enable_multibyte_characters) = multibyte ? Qt : Qnil; set_buffer_internal (current); return workbuf; } @@ -7562,7 +7562,7 @@ decode_coding_gap (struct coding_system *coding, coding->dst_object = coding->src_object; coding->dst_pos = PT; coding->dst_pos_byte = PT_BYTE; - coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); + coding->dst_multibyte = ! NILP (B_ (current_buffer, enable_multibyte_characters)); if (CODING_REQUIRE_DETECTION (coding)) detect_coding (coding); @@ -7728,7 +7728,7 @@ decode_coding_object (struct coding_system *coding, coding->dst_pos = BUF_PT (XBUFFER (dst_object)); coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); coding->dst_multibyte - = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); + = ! NILP (B_ (XBUFFER (dst_object), enable_multibyte_characters)); } else { @@ -7798,7 +7798,7 @@ decode_coding_object (struct coding_system *coding, TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); else if (saved_pt < from + chars) TEMP_SET_PT_BOTH (from, from_byte); - else if (! NILP (current_buffer->enable_multibyte_characters)) + else if (! NILP (B_ (current_buffer, enable_multibyte_characters))) TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), saved_pt_byte + (coding->produced - bytes)); else @@ -7822,7 +7822,7 @@ decode_coding_object (struct coding_system *coding, { tail->bytepos = from_byte + coding->produced; tail->charpos - = (NILP (current_buffer->enable_multibyte_characters) + = (NILP (B_ (current_buffer, enable_multibyte_characters)) ? tail->bytepos : from + coding->produced_char); } } @@ -7960,7 +7960,7 @@ encode_coding_object (struct coding_system *coding, set_buffer_temp (current); } coding->dst_multibyte - = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); + = ! NILP (B_ (XBUFFER (dst_object), enable_multibyte_characters)); } else if (EQ (dst_object, Qt)) { @@ -8003,7 +8003,7 @@ encode_coding_object (struct coding_system *coding, TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); else if (saved_pt < from + chars) TEMP_SET_PT_BOTH (from, from_byte); - else if (! NILP (current_buffer->enable_multibyte_characters)) + else if (! NILP (B_ (current_buffer, enable_multibyte_characters))) TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), saved_pt_byte + (coding->produced - bytes)); else @@ -8027,7 +8027,7 @@ encode_coding_object (struct coding_system *coding, { tail->bytepos = from_byte + coding->produced; tail->charpos - = (NILP (current_buffer->enable_multibyte_characters) + = (NILP (B_ (current_buffer, enable_multibyte_characters)) ? tail->bytepos : from + coding->produced_char); } } @@ -8481,8 +8481,8 @@ highest priority. */) return detect_coding_system (BYTE_POS_ADDR (from_byte), to - from, to_byte - from_byte, !NILP (highest), - !NILP (current_buffer - ->enable_multibyte_characters), + !NILP (B_ (current_buffer + , enable_multibyte_characters)), Qnil); } @@ -8564,7 +8564,7 @@ DEFUN ("find-coding-systems-region-internal", CHECK_NUMBER_COERCE_MARKER (end); if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) args_out_of_range (start, end); - if (NILP (current_buffer->enable_multibyte_characters)) + if (NILP (B_ (current_buffer, enable_multibyte_characters))) return Qt; start_byte = CHAR_TO_BYTE (XINT (start)); end_byte = CHAR_TO_BYTE (XINT (end)); @@ -8698,7 +8698,7 @@ to the string. */) validate_region (&start, &end); from = XINT (start); to = XINT (end); - if (NILP (current_buffer->enable_multibyte_characters) + if (NILP (B_ (current_buffer, enable_multibyte_characters)) || (ascii_compatible && (to - from) == (CHAR_TO_BYTE (to) - (CHAR_TO_BYTE (from))))) return Qnil; @@ -8814,7 +8814,7 @@ is nil. */) CHECK_NUMBER_COERCE_MARKER (end); if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) args_out_of_range (start, end); - if (NILP (current_buffer->enable_multibyte_characters)) + if (NILP (B_ (current_buffer, enable_multibyte_characters))) return Qnil; start_byte = CHAR_TO_BYTE (XINT (start)); end_byte = CHAR_TO_BYTE (XINT (end)); -- cgit v1.2.1 From 4b4deea229a39c94762dcf49da538b639df59148 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 16 Feb 2011 08:02:50 -0700 Subject: Change B_ to BVAR * xfns.c (x_create_tip_frame, Fx_show_tip): Replace B_ with BVAR. * xfaces.c (compute_char_face): Replace B_ with BVAR. * xdisp.c (pos_visible_p, init_iterator, reseat_1) (message_dolog, update_echo_area, ensure_echo_area_buffers) (with_echo_area_buffer, setup_echo_area_for_printing) (set_message_1, update_menu_bar, update_tool_bar) (text_outside_line_unchanged_p, redisplay_internal) (try_scrolling, try_cursor_movement, redisplay_window) (try_window_reusing_current_matrix, row_containing_pos) (try_window_id, get_overlay_arrow_glyph_row, display_line) (Fcurrent_bidi_paragraph_direction, display_mode_lines) (decode_mode_spec_coding, decode_mode_spec, display_count_lines) (get_window_cursor_type, note_mouse_highlight): Replace B_ with BVAR. * window.c (window_display_table, unshow_buffer, window_loop) (window_min_size_2, set_window_buffer, Fset_window_buffer) (select_window, Fforce_window_update, temp_output_buffer_show) (Fset_window_configuration, save_window_save): Replace B_ with BVAR. * w32fns.c (x_create_tip_frame, Fx_show_tip, Fw32_shell_execute): Replace B_ with BVAR. * undo.c (record_point, record_insert, record_delete) (record_marker_adjustment, record_first_change) (record_property_change, Fundo_boundary, truncate_undo_list) (Fprimitive_undo): Replace B_ with BVAR. * syntax.h (Vstandard_syntax_table, CURRENT_SYNTAX_TABLE) (SETUP_BUFFER_SYNTAX_TABLE): Replace B_ with BVAR. * syntax.c (update_syntax_table, dec_bytepos, Fsyntax_table) (Fset_syntax_table, Fmodify_syntax_entry, skip_chars) (skip_syntaxes, scan_lists): Replace B_ with BVAR. * search.c (compile_pattern_1, compile_pattern, looking_at_1) (string_match_1, fast_looking_at, newline_cache_on_off) (search_command, search_buffer, simple_search, boyer_moore) (Freplace_match): Replace B_ with BVAR. * process.c (get_process, list_processes_1, Fstart_process) (Fmake_serial_process, Fmake_network_process) (read_process_output, send_process, exec_sentinel) (status_notify, setup_process_coding_systems): Replace B_ with BVAR. * print.c (PRINTDECLARE, PRINTPREPARE, PRINTFINISH, printchar) (strout, print_string, temp_output_buffer_setup, print_object): Replace B_ with BVAR. * msdos.c (IT_frame_up_to_date): Replace B_ with BVAR. * minibuf.c (read_minibuf, get_minibuffer, Fread_buffer): Replace B_ with BVAR. * marker.c (Fmarker_buffer, Fset_marker, set_marker_restricted) (set_marker_both, set_marker_restricted_both, unchain_marker): Replace B_ with BVAR. * lread.c (readchar, unreadchar, openp, readevalloop) (Feval_buffer, Feval_region): Replace B_ with BVAR. * lisp.h (DOWNCASE_TABLE, UPCASE_TABLE): Replace B_ with BVAR. * keymap.c (Flocal_key_binding, Fuse_local_map) (Fcurrent_local_map, push_key_description) (Fdescribe_buffer_bindings): Replace B_ with BVAR. * keyboard.c (command_loop_1, read_char_minibuf_menu_prompt) (read_key_sequence): Replace B_ with BVAR. * intervals.h (TEXT_PROP_MEANS_INVISIBLE): Replace B_ with BVAR. * intervals.c (set_point_both, get_local_map): Replace B_ with BVAR. * insdel.c (check_markers, insert_char, insert_1_both) (insert_from_string_1, insert_from_gap, insert_from_buffer_1) (adjust_after_replace, replace_range, del_range_2) (modify_region, prepare_to_modify_buffer) (Fcombine_after_change_execute): Replace B_ with BVAR. * indent.c (buffer_display_table, recompute_width_table) (width_run_cache_on_off, current_column, scan_for_column) (Findent_to, position_indentation, compute_motion, vmotion): Replace B_ with BVAR. * fringe.c (get_logical_cursor_bitmap) (get_logical_fringe_bitmap, update_window_fringes): Replace B_ with BVAR. * frame.c (make_frame_visible_1): Replace B_ with BVAR. * font.c (font_at): Replace B_ with BVAR. * fns.c (Fbase64_encode_region, Fbase64_decode_region, Fmd5): Replace B_ with BVAR. * filelock.c (unlock_all_files, Flock_buffer, Funlock_buffer) (unlock_buffer): Replace B_ with BVAR. * fileio.c (Fexpand_file_name, Ffile_directory_p) (Ffile_regular_p, Ffile_selinux_context) (Fset_file_selinux_context, Ffile_modes, Fset_file_modes) (Fset_file_times, Ffile_newer_than_file_p, decide_coding_unwind) (Finsert_file_contents, choose_write_coding_system) (Fwrite_region, build_annotations, Fverify_visited_file_modtime) (Fset_visited_file_modtime, auto_save_error, auto_save_1) (Fdo_auto_save, Fset_buffer_auto_saved): Replace B_ with BVAR. * editfns.c (region_limit, Fmark_marker, save_excursion_save) (save_excursion_restore, Fprevious_char, Fchar_before) (general_insert_function, Finsert_char, Finsert_byte) (make_buffer_string_both, Finsert_buffer_substring) (Fcompare_buffer_substrings, subst_char_in_region_unwind) (subst_char_in_region_unwind_1, Fsubst_char_in_region) (Ftranslate_region_internal, save_restriction_restore) (Fchar_equal): Replace B_ with BVAR. * dispnew.c (Fframe_or_buffer_changed_p): Replace B_ with BVAR. * dispextern.h (WINDOW_WANTS_MODELINE_P) (WINDOW_WANTS_HEADER_LINE_P): Replace B_ with BVAR. * dired.c (directory_files_internal): Replace B_ with BVAR. * data.c (swap_in_symval_forwarding, set_internal) (Fmake_local_variable, Fkill_local_variable, Flocal_variable_p): Replace B_ with BVAR. * composite.c (fill_gstring_header) (composition_compute_stop_pos, composition_adjust_point) (Ffind_composition_internal): Replace B_ with BVAR. * coding.c (decode_coding, encode_coding) (make_conversion_work_buffer, decode_coding_gap) (decode_coding_object, encode_coding_object) (Fdetect_coding_region, Ffind_coding_systems_region_internal) (Funencodable_char_position, Fcheck_coding_systems_region): Replace B_ with BVAR. * cmds.c (Fself_insert_command, internal_self_insert): Replace B_ with BVAR. * charset.c (Ffind_charset_region): Replace B_ with BVAR. * character.h (FETCH_CHAR_ADVANCE, INC_BOTH, DEC_BOTH) (ASCII_CHAR_WIDTH): Replace B_ with BVAR. * character.c (chars_in_text, Fget_byte): Replace B_ with BVAR. * category.h (Vstandard_category_table): Replace B_ with BVAR. * category.c (check_category_table, Fcategory_table) (Fset_category_table, char_category_set): Replace B_ with BVAR. * casetab.c (Fcurrent_case_table, set_case_table): Replace B_ with BVAR. * casefiddle.c (casify_object, casify_region): Replace B_ with BVAR. * callproc.c (Fcall_process, Fcall_process_region): Replace B_ with BVAR. * callint.c (check_mark, Fcall_interactively): Replace B_ with BVAR. * bytecode.c (Fbyte_code): Replace B_ with BVAR. * buffer.h (FETCH_CHAR, FETCH_CHAR_AS_MULTIBYTE, BVAR): Replace B_ with BVAR. * buffer.c (Fbuffer_live_p, Fget_file_buffer) (get_truename_buffer, Fget_buffer_create) (clone_per_buffer_values, Fmake_indirect_buffer, reset_buffer) (reset_buffer_local_variables, Fbuffer_name, Fbuffer_file_name) (Fbuffer_local_value, buffer_lisp_local_variables) (Fset_buffer_modified_p, Frestore_buffer_modified_p) (Frename_buffer, Fother_buffer, Fbuffer_enable_undo) (Fkill_buffer, Fset_buffer_major_mode, set_buffer_internal_1) (set_buffer_temp, Fset_buffer, set_buffer_if_live) (Fbarf_if_buffer_read_only, Fbury_buffer, Ferase_buffer) (Fbuffer_swap_text, swapfield_, Fbuffer_swap_text) (Fset_buffer_multibyte, swap_out_buffer_local_variables) (record_overlay_string, overlay_strings, init_buffer_once) (init_buffer, syms_of_buffer): Replace B_ with BVAR. --- src/coding.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 899cca6d5aa..f6310369ad3 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7038,8 +7038,8 @@ decode_coding (struct coding_system *coding) set_buffer_internal (XBUFFER (coding->dst_object)); if (GPT != PT) move_gap_both (PT, PT_BYTE); - undo_list = B_ (current_buffer, undo_list); - B_ (current_buffer, undo_list) = Qt; + undo_list = BVAR (current_buffer, undo_list); + BVAR (current_buffer, undo_list) = Qt; } coding->consumed = coding->consumed_char = 0; @@ -7136,7 +7136,7 @@ decode_coding (struct coding_system *coding) decode_eol (coding); if (BUFFERP (coding->dst_object)) { - B_ (current_buffer, undo_list) = undo_list; + BVAR (current_buffer, undo_list) = undo_list; record_insert (coding->dst_pos, coding->produced_char); } return coding->result; @@ -7433,7 +7433,7 @@ encode_coding (struct coding_system *coding) { set_buffer_internal (XBUFFER (coding->dst_object)); coding->dst_multibyte - = ! NILP (B_ (current_buffer, enable_multibyte_characters)); + = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); } coding->consumed = coding->consumed_char = 0; @@ -7504,8 +7504,8 @@ make_conversion_work_buffer (int multibyte) doesn't compile new regexps. */ Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); Ferase_buffer (); - B_ (current_buffer, undo_list) = Qt; - B_ (current_buffer, enable_multibyte_characters) = multibyte ? Qt : Qnil; + BVAR (current_buffer, undo_list) = Qt; + BVAR (current_buffer, enable_multibyte_characters) = multibyte ? Qt : Qnil; set_buffer_internal (current); return workbuf; } @@ -7562,7 +7562,7 @@ decode_coding_gap (struct coding_system *coding, coding->dst_object = coding->src_object; coding->dst_pos = PT; coding->dst_pos_byte = PT_BYTE; - coding->dst_multibyte = ! NILP (B_ (current_buffer, enable_multibyte_characters)); + coding->dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); if (CODING_REQUIRE_DETECTION (coding)) detect_coding (coding); @@ -7728,7 +7728,7 @@ decode_coding_object (struct coding_system *coding, coding->dst_pos = BUF_PT (XBUFFER (dst_object)); coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); coding->dst_multibyte - = ! NILP (B_ (XBUFFER (dst_object), enable_multibyte_characters)); + = ! NILP (BVAR (XBUFFER (dst_object), enable_multibyte_characters)); } else { @@ -7798,7 +7798,7 @@ decode_coding_object (struct coding_system *coding, TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); else if (saved_pt < from + chars) TEMP_SET_PT_BOTH (from, from_byte); - else if (! NILP (B_ (current_buffer, enable_multibyte_characters))) + else if (! NILP (BVAR (current_buffer, enable_multibyte_characters))) TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), saved_pt_byte + (coding->produced - bytes)); else @@ -7822,7 +7822,7 @@ decode_coding_object (struct coding_system *coding, { tail->bytepos = from_byte + coding->produced; tail->charpos - = (NILP (B_ (current_buffer, enable_multibyte_characters)) + = (NILP (BVAR (current_buffer, enable_multibyte_characters)) ? tail->bytepos : from + coding->produced_char); } } @@ -7960,7 +7960,7 @@ encode_coding_object (struct coding_system *coding, set_buffer_temp (current); } coding->dst_multibyte - = ! NILP (B_ (XBUFFER (dst_object), enable_multibyte_characters)); + = ! NILP (BVAR (XBUFFER (dst_object), enable_multibyte_characters)); } else if (EQ (dst_object, Qt)) { @@ -8003,7 +8003,7 @@ encode_coding_object (struct coding_system *coding, TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte); else if (saved_pt < from + chars) TEMP_SET_PT_BOTH (from, from_byte); - else if (! NILP (B_ (current_buffer, enable_multibyte_characters))) + else if (! NILP (BVAR (current_buffer, enable_multibyte_characters))) TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars), saved_pt_byte + (coding->produced - bytes)); else @@ -8027,7 +8027,7 @@ encode_coding_object (struct coding_system *coding, { tail->bytepos = from_byte + coding->produced; tail->charpos - = (NILP (B_ (current_buffer, enable_multibyte_characters)) + = (NILP (BVAR (current_buffer, enable_multibyte_characters)) ? tail->bytepos : from + coding->produced_char); } } @@ -8481,7 +8481,7 @@ highest priority. */) return detect_coding_system (BYTE_POS_ADDR (from_byte), to - from, to_byte - from_byte, !NILP (highest), - !NILP (B_ (current_buffer + !NILP (BVAR (current_buffer , enable_multibyte_characters)), Qnil); } @@ -8564,7 +8564,7 @@ DEFUN ("find-coding-systems-region-internal", CHECK_NUMBER_COERCE_MARKER (end); if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) args_out_of_range (start, end); - if (NILP (B_ (current_buffer, enable_multibyte_characters))) + if (NILP (BVAR (current_buffer, enable_multibyte_characters))) return Qt; start_byte = CHAR_TO_BYTE (XINT (start)); end_byte = CHAR_TO_BYTE (XINT (end)); @@ -8698,7 +8698,7 @@ to the string. */) validate_region (&start, &end); from = XINT (start); to = XINT (end); - if (NILP (B_ (current_buffer, enable_multibyte_characters)) + if (NILP (BVAR (current_buffer, enable_multibyte_characters)) || (ascii_compatible && (to - from) == (CHAR_TO_BYTE (to) - (CHAR_TO_BYTE (from))))) return Qnil; @@ -8814,7 +8814,7 @@ is nil. */) CHECK_NUMBER_COERCE_MARKER (end); if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end)) args_out_of_range (start, end); - if (NILP (B_ (current_buffer, enable_multibyte_characters))) + if (NILP (BVAR (current_buffer, enable_multibyte_characters))) return Qnil; start_byte = CHAR_TO_BYTE (XINT (start)); end_byte = CHAR_TO_BYTE (XINT (end)); -- cgit v1.2.1 From f38b440c4b40777c25631323f2501ffb5ba98251 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 17:41:19 -0800 Subject: * coding.c (coding_set_source, coding_set_destination): Use "else { /* comment */ }" rather than "else /* comment */;" for clarity, and to avoid gcc -Wempty-body warning. --- src/coding.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index f6310369ad3..cb13793daba 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1051,9 +1051,10 @@ coding_set_source (struct coding_system *coding) coding->source = SDATA (coding->src_object) + coding->src_pos_byte; } else - /* Otherwise, the source is C string and is never relocated - automatically. Thus we don't have to update anything. */ - ; + { + /* Otherwise, the source is C string and is never relocated + automatically. Thus we don't have to update anything. */ + } } static void @@ -1079,9 +1080,10 @@ coding_set_destination (struct coding_system *coding) } } else - /* Otherwise, the destination is C string and is never relocated - automatically. Thus we don't have to update anything. */ - ; + { + /* Otherwise, the destination is C string and is never relocated + automatically. Thus we don't have to update anything. */ + } } -- cgit v1.2.1 From 2735d0606bd871584b2e6343f3dce4c1a155b296 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 20:37:19 -0800 Subject: * coding.c (Fdefine_coding_system_internal): Don't redeclare 'i' inside a block, when the outer 'i' will do. (decode_coding_utf_8, decode_coding_utf_16, detect_coding_emacs_mule): (emacs_mule_char, decode_coding_emacs_mule, detect_coding_iso_2022): (decode_coding_iso_2022, decode_coding_sjis, decode_coding_big5): (decode_coding_raw_text, decode_coding_charset, get_translation_table): (Fdecode_sjis_char, Fdefine_coding_system_internal): Rename locals to avoid shadowing. * character.h (FETCH_STRING_CHAR_ADVANCE): Likewise. --- src/coding.c | 101 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 51 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index cb13793daba..495e8148b05 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1320,7 +1320,7 @@ decode_coding_utf_8 (struct coding_system *coding) int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); Lisp_Object attr, charset_list; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -1381,7 +1381,7 @@ decode_coding_utf_8 (struct coding_system *coding) } else if (UTF_8_1_OCTET_P (c1)) { - if (eol_crlf && c1 == '\r') + if (eol_dos && c1 == '\r') ONE_MORE_BYTE (byte_after_cr); c = c1; } @@ -1639,7 +1639,7 @@ decode_coding_utf_16 (struct coding_system *coding) enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); int surrogate = CODING_UTF_16_SURROGATE (coding); Lisp_Object attr, charset_list; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr1 = -1, byte_after_cr2 = -1; @@ -1736,7 +1736,7 @@ decode_coding_utf_16 (struct coding_system *coding) CODING_UTF_16_SURROGATE (coding) = surrogate = c; else { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') { ONE_MORE_BYTE (byte_after_cr1); ONE_MORE_BYTE (byte_after_cr2); @@ -1920,17 +1920,17 @@ detect_coding_emacs_mule (struct coding_system *coding, it because analyzing it is too heavy for detecting. But, at least, we check that the composite character constitutes of more than 4 bytes. */ - const unsigned char *src_base; + const unsigned char *src_start; repeat: - src_base = src; + src_start = src; do { ONE_MORE_BYTE (c); } while (c >= 0xA0); - if (src - src_base <= 4) + if (src - src_start <= 4) break; found = CATEGORY_MASK_EMACS_MULE; if (c == 0x80) @@ -1990,7 +1990,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, const unsigned char *src_end = coding->source + coding->src_bytes; const unsigned char *src_base = src; int multibytep = coding->src_multibyte; - int charset_id; + int charset_ID; unsigned code; int c; int consumed_chars = 0; @@ -2000,7 +2000,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, if (c < 0) { c = -c; - charset_id = emacs_mule_charset[0]; + charset_ID = emacs_mule_charset[0]; } else { @@ -2036,7 +2036,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, switch (emacs_mule_bytes[c]) { case 2: - if ((charset_id = emacs_mule_charset[c]) < 0) + if ((charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2049,7 +2049,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, || c == EMACS_MULE_LEADING_CODE_PRIVATE_12) { ONE_MORE_BYTE (c); - if (c < 0xA0 || (charset_id = emacs_mule_charset[c]) < 0) + if (c < 0xA0 || (charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2058,7 +2058,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, } else { - if ((charset_id = emacs_mule_charset[c]) < 0) + if ((charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2073,7 +2073,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, case 4: ONE_MORE_BYTE (c); - if (c < 0 || (charset_id = emacs_mule_charset[c]) < 0) + if (c < 0 || (charset_ID = emacs_mule_charset[c]) < 0) goto invalid_code; ONE_MORE_BYTE (c); if (c < 0xA0) @@ -2087,21 +2087,21 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, case 1: code = c; - charset_id = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit; + charset_ID = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit; break; default: abort (); } CODING_DECODE_CHAR (coding, src, src_base, src_end, - CHARSET_FROM_ID (charset_id), code, c); + CHARSET_FROM_ID (charset_ID), code, c); if (c < 0) goto invalid_code; } *nbytes = src - src_base; *nchars = consumed_chars; if (id) - *id = charset_id; + *id = charset_ID; return (mseq_found ? -c : c); no_more_source: @@ -2374,7 +2374,7 @@ decode_coding_emacs_mule (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; @@ -2424,7 +2424,7 @@ decode_coding_emacs_mule (struct coding_system *coding) if (c < 0x80) { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); id = charset_ascii; if (cmp_status->state != COMPOSING_NO) @@ -3160,7 +3160,7 @@ detect_coding_iso_2022 (struct coding_system *coding, if (! single_shifting && ! (rejected & CATEGORY_MASK_ISO_8_2)) { - int i = 1; + int len = 1; while (src < src_end) { src_base = src; @@ -3170,20 +3170,20 @@ detect_coding_iso_2022 (struct coding_system *coding, src = src_base; break; } - i++; + len++; } - if (i & 1 && src < src_end) + if (len & 1 && src < src_end) { rejected |= CATEGORY_MASK_ISO_8_2; if (composition_count >= 0) - composition_count += i; + composition_count += len; } else { found |= CATEGORY_MASK_ISO_8_2; if (composition_count >= 0) - composition_count += i / 2; + composition_count += len / 2; } } break; @@ -3311,10 +3311,10 @@ detect_coding_iso_2022 (struct coding_system *coding, } \ else /* new format (after ver.21) */ \ { \ - int c; \ + int b; \ \ - ONE_MORE_BYTE (c); \ - rule = COMPOSITION_ENCODE_RULE (rule - 81, c - 32); \ + ONE_MORE_BYTE (b); \ + rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ if (rule >= 0) \ rule += 0x100; /* to destinguish it from the old format */ \ nbytes = 2; \ @@ -3506,7 +3506,7 @@ decode_coding_iso_2022 (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; int i; @@ -3626,7 +3626,7 @@ decode_coding_iso_2022 (struct coding_system *coding) break; case ISO_control_0: - if (eol_crlf && c1 == '\r') + if (eol_dos && c1 == '\r') ONE_MORE_BYTE (byte_after_cr); MAYBE_FINISH_COMPOSITION (); charset = CHARSET_FROM_ID (charset_ascii); @@ -4031,7 +4031,6 @@ decode_coding_iso_2022 (struct coding_system *coding) const char *intermediate_char_94 = "()*+"; \ const char *intermediate_char_96 = ",-./"; \ int revision = -1; \ - int c; \ \ if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \ revision = CHARSET_ISO_REVISION (charset); \ @@ -4044,11 +4043,12 @@ decode_coding_iso_2022 (struct coding_system *coding) EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \ if (CHARSET_DIMENSION (charset) == 1) \ { \ + int b; \ if (! CHARSET_ISO_CHARS_96 (charset)) \ - c = intermediate_char_94[reg]; \ + b = intermediate_char_94[reg]; \ else \ - c = intermediate_char_96[reg]; \ - EMIT_ONE_ASCII_BYTE (c); \ + b = intermediate_char_96[reg]; \ + EMIT_ONE_ASCII_BYTE (b); \ } \ else \ { \ @@ -4709,7 +4709,7 @@ decode_coding_sjis (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -4744,7 +4744,7 @@ decode_coding_sjis (struct coding_system *coding) goto invalid_code; if (c < 0x80) { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); charset = charset_roman; } @@ -4826,7 +4826,7 @@ decode_coding_big5 (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -4859,7 +4859,7 @@ decode_coding_big5 (struct coding_system *coding) goto invalid_code; if (c < 0x80) { - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); charset = charset_roman; } @@ -5263,13 +5263,13 @@ encode_coding_ccl (struct coding_system *coding) static void decode_coding_raw_text (struct coding_system *coding) { - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); coding->chars_at_source = 1; coding->consumed_char = coding->src_chars; coding->consumed = coding->src_bytes; - if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r') + if (eol_dos && coding->source[coding->src_bytes - 1] == '\r') { coding->consumed_char--; coding->consumed--; @@ -5482,7 +5482,7 @@ decode_coding_charset (struct coding_system *coding) int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; - int eol_crlf = + int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; @@ -5516,7 +5516,7 @@ decode_coding_charset (struct coding_system *coding) else { ONE_MORE_BYTE (c); - if (eol_crlf && c == '\r') + if (eol_dos && c == '\r') ONE_MORE_BYTE (byte_after_cr); } if (c < 0) @@ -6609,15 +6609,15 @@ get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) } else if (CONSP (translation_table)) { - Lisp_Object tail, val; + Lisp_Object tail; for (tail = translation_table; CONSP (tail); tail = XCDR (tail)) if (CHAR_TABLE_P (XCAR (tail)) && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1) { - val = XCHAR_TABLE (XCAR (tail))->extras[1]; - if (NATNUMP (val) && *max_lookup < XFASTINT (val)) - *max_lookup = XFASTINT (val); + Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1]; + if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval)) + *max_lookup = XFASTINT (tailval); } } } @@ -9114,10 +9114,10 @@ Return the corresponding character. */) } else { - int s1 = c >> 8, s2 = c & 0xFF; + int c1 = c >> 8, c2 = c & 0xFF; - if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF - || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC) + if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF + || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) error ("Invalid code: %d", code); SJIS_TO_JIS (c); charset = charset_kanji; @@ -9800,7 +9800,6 @@ usage: (define-coding-system-internal ...) */) else if (EQ (coding_type, Qiso_2022)) { Lisp_Object initial, reg_usage, request, flags; - int i; if (nargs < coding_arg_iso2022_max) goto short_args; @@ -9832,12 +9831,12 @@ usage: (define-coding-system-internal ...) */) for (tail = request; ! NILP (tail); tail = Fcdr (tail)) { int id; - Lisp_Object tmp; + Lisp_Object tmp1; val = Fcar (tail); CHECK_CONS (val); - tmp = XCAR (val); - CHECK_CHARSET_GET_ID (tmp, id); + tmp1 = XCAR (val); + CHECK_CHARSET_GET_ID (tmp1, id); CHECK_NATNUM_CDR (val); if (XINT (XCDR (val)) >= 4) error ("Invalid graphic register number: %d", XINT (XCDR (val))); -- cgit v1.2.1 From e2f1bab96318b2809aad624ee9bbbdfd7fd6dd6e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 20:41:22 -0800 Subject: * coding.c (emacs_mule_char, encode_invocation_designation): Now static, since they're not used elsewhere. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 495e8148b05..4fdbd1fd752 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1982,7 +1982,7 @@ detect_coding_emacs_mule (struct coding_system *coding, the decoded character or rule. If an invalid byte is found, return -1. If SRC is too short, return -2. */ -int +static int emacs_mule_char (struct coding_system *coding, const unsigned char *src, int *nbytes, int *nchars, int *id, struct composition_status *cmp_status) @@ -4228,7 +4228,7 @@ decode_coding_iso_2022 (struct coding_system *coding) to use CHARSET. The element `spec.iso_2022' of *CODING is updated. Return new DST. */ -unsigned char * +static unsigned char * encode_invocation_designation (struct charset *charset, struct coding_system *coding, unsigned char *dst, int *p_nchars) -- cgit v1.2.1 From 413bb2db753528a2e4bd70f8bbabcd232b11b6d7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 21:28:41 -0800 Subject: * coding.c (decode_coding_iso_2022): Add "default: abort ();" as a safety check. --- src/coding.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 4fdbd1fd752..c9d32489351 100644 --- a/src/coding.c +++ b/src/coding.c @@ -3899,6 +3899,10 @@ decode_coding_iso_2022 (struct coding_system *coding) } continue; } + break; + + default: + abort (); } if (cmp_status->state == COMPOSING_NO -- cgit v1.2.1 From c4a63b128d3f8405fa1037e0c22bd8fabcbdd123 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:12:45 -0800 Subject: * coding.c: (decode_coding_object, encode_coding_object, detect_coding_system): Mark variables that gcc -Wuninitialized does not deduce are never used uninitialized. --- src/coding.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index c9d32489351..75fc92eee8d 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7658,12 +7658,12 @@ decode_coding_object (struct coding_system *coding, Lisp_Object dst_object) { int count = SPECPDL_INDEX (); - unsigned char *destination; - EMACS_INT dst_bytes; + unsigned char *destination IF_LINT (= NULL); + EMACS_INT dst_bytes IF_LINT (= 0); EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte; + int saved_pt = -1, saved_pt_byte IF_LINT (= 0); int need_marker_adjustment = 0; Lisp_Object old_deactivate_mark; @@ -7851,7 +7851,7 @@ encode_coding_object (struct coding_system *coding, EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte; + int saved_pt = -1, saved_pt_byte IF_LINT (= 0); int need_marker_adjustment = 0; int kill_src_buffer = 0; Lisp_Object old_deactivate_mark; @@ -8184,8 +8184,8 @@ detect_coding_system (const unsigned char *src, base_category = XINT (CODING_ATTR_CATEGORY (attrs)); if (base_category == coding_category_undecided) { - enum coding_category category; - struct coding_system *this; + enum coding_category category IF_LINT (= 0); + struct coding_system *this IF_LINT (= NULL); int c, i; /* Skip all ASCII bytes except for a few ISO2022 controls. */ -- cgit v1.2.1 From 5f58e762f919864376efe785253006590a1e4dc5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:23:55 -0800 Subject: * coding.c: (ISO_CODE_LF, ISO_CODE_CR, CODING_ISO_FLAG_EUC_TW_SHIFT): (ONE_MORE_BYTE_NO_CHECK, UTF_BOM, UTF_16_INVALID_P): (SHIFT_OUT_OK, ENCODE_CONTROL_SEQUENCE_INTRODUCER): (ENCODE_DIRECTION_R2L, ENCODE_DIRECTION_L2R): Remove unused macros. --- src/coding.c | 57 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 75fc92eee8d..3df34cea173 100644 --- a/src/coding.c +++ b/src/coding.c @@ -395,8 +395,6 @@ Lisp_Object Vbig5_coding_system; /* Control characters of ISO2022. */ /* code */ /* function */ -#define ISO_CODE_LF 0x0A /* line-feed */ -#define ISO_CODE_CR 0x0D /* carriage-return */ #define ISO_CODE_SO 0x0E /* shift-out */ #define ISO_CODE_SI 0x0F /* shift-in */ #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ @@ -479,7 +477,7 @@ enum iso_code_class_type #define CODING_ISO_FLAG_COMPOSITION 0x2000 -#define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 +/* #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 */ #define CODING_ISO_FLAG_USE_ROMAN 0x8000 @@ -721,25 +719,6 @@ static struct coding_system coding_categories[coding_category_max]; } while (0) -#define ONE_MORE_BYTE_NO_CHECK(c) \ - do { \ - c = *src++; \ - if (multibytep && (c & 0x80)) \ - { \ - if ((c & 0xFE) == 0xC0) \ - c = ((c & 1) << 6) | *src++; \ - else \ - { \ - src--; \ - c = - string_char (src, &src, NULL); \ - record_conversion_result \ - (coding, CODING_RESULT_INVALID_SRC); \ - } \ - } \ - consumed_chars++; \ - } while (0) - - /* Store a byte C in the place pointed by DST and increment DST to the next free point, and increment PRODUCED_CHARS. The caller should assure that C is 0..127, and declare and set the variable `dst' @@ -1219,7 +1198,6 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes, #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) -#define UTF_BOM 0xFEFF #define UTF_8_BOM_1 0xEF #define UTF_8_BOM_2 0xBB #define UTF_8_BOM_3 0xBF @@ -1535,11 +1513,6 @@ encode_coding_utf_8 (struct coding_system *coding) #define UTF_16_LOW_SURROGATE_P(val) \ (((val) & 0xFC00) == 0xDC00) -#define UTF_16_INVALID_P(val) \ - (((val) == 0xFFFE) \ - || ((val) == 0xFFFF) \ - || UTF_16_LOW_SURROGATE_P (val)) - static int detect_coding_utf_16 (struct coding_system *coding, @@ -2905,10 +2878,6 @@ enum iso_code_class_type iso_code_class[256]; ((id) <= (coding)->max_charset_id \ && (coding)->safe_charsets[id] != 255) - -#define SHIFT_OUT_OK(category) \ - (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) - static void setup_iso_safe_charsets (Lisp_Object attrs) { @@ -4295,30 +4264,6 @@ encode_invocation_designation (struct charset *charset, return dst; } -/* The following three macros produce codes for indicating direction - of text. */ -#define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ - do { \ - if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ - EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ - else \ - EMIT_ONE_BYTE (ISO_CODE_CSI); \ - } while (0) - - -#define ENCODE_DIRECTION_R2L() \ - do { \ - ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ - EMIT_TWO_ASCII_BYTES ('2', ']'); \ - } while (0) - - -#define ENCODE_DIRECTION_L2R() \ - do { \ - ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ - EMIT_TWO_ASCII_BYTES ('0', ']'); \ - } while (0) - /* Produce codes for designation and invocation to reset the graphic planes and registers to initial state. */ -- cgit v1.2.1 From ee05f96119932f5e4f33b59e1a2f4abdd9c0a34a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:34:38 -0800 Subject: * coding.c (decode_coding_emacs_mule): Mark variables that gcc -Wuninitialized does not deduce are never used uninitialized. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 3df34cea173..096268d1a72 100644 --- a/src/coding.c +++ b/src/coding.c @@ -2365,7 +2365,7 @@ decode_coding_emacs_mule (struct coding_system *coding) while (1) { - int c, id; + int c, id IF_LINT (= 0); src_base = src; consumed_chars_base = consumed_chars; @@ -2410,7 +2410,7 @@ decode_coding_emacs_mule (struct coding_system *coding) } else { - int nchars, nbytes; + int nchars IF_LINT (= 0), nbytes IF_LINT (= 0); /* emacs_mule_char can load a charset map from a file, which allocates a large structure and might cause buffer text to be relocated as result. Thus, we need to remember the -- cgit v1.2.1 From 160b01f65a12a9e6893c270662d6ae249a1db300 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:36:31 -0800 Subject: * coding.c (detect_coding_iso_2022): Initialize a local variable that might be used uninitialized. Leave a FIXME because it's not clear that this initialization is needed. --- src/coding.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 096268d1a72..9a6a4484e50 100644 --- a/src/coding.c +++ b/src/coding.c @@ -2954,7 +2954,12 @@ detect_coding_iso_2022 (struct coding_system *coding, const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; int single_shifting = 0; - int id; + + /* FIXME: Does ID need to be initialized here? The "End of composition" + code below does not initialize ID even though ID is used + afterwards, and perhaps that is a bug. */ + int id = 0; + int c, c1; int consumed_chars = 0; int i; -- cgit v1.2.1 From 0e48bb227a5b9cdabeb845422de33d62ccb1edc5 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 15 Mar 2011 19:38:57 +0100 Subject: * src/coding.c (detect_coding_iso_2022): Reorganize code to clarify structure. --- src/coding.c | 159 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 80 insertions(+), 79 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 9a6a4484e50..0c2836c19f6 100644 --- a/src/coding.c +++ b/src/coding.c @@ -2954,12 +2954,7 @@ detect_coding_iso_2022 (struct coding_system *coding, const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; int single_shifting = 0; - - /* FIXME: Does ID need to be initialized here? The "End of composition" - code below does not initialize ID even though ID is used - afterwards, and perhaps that is a bug. */ - int id = 0; - + int id; int c, c1; int consumed_chars = 0; int i; @@ -2999,40 +2994,11 @@ detect_coding_iso_2022 (struct coding_system *coding, break; single_shifting = 0; ONE_MORE_BYTE (c); - if (c >= '(' && c <= '/') - { - /* Designation sequence for a charset of dimension 1. */ - ONE_MORE_BYTE (c1); - if (c1 < ' ' || c1 >= 0x80 - || (id = iso_charset_table[0][c >= ','][c1]) < 0) - /* Invalid designation sequence. Just ignore. */ - break; - } - else if (c == '$') - { - /* Designation sequence for a charset of dimension 2. */ - ONE_MORE_BYTE (c); - if (c >= '@' && c <= 'B') - /* Designation for JISX0208.1978, GB2312, or JISX0208. */ - id = iso_charset_table[1][0][c]; - else if (c >= '(' && c <= '/') - { - ONE_MORE_BYTE (c1); - if (c1 < ' ' || c1 >= 0x80 - || (id = iso_charset_table[1][c >= ','][c1]) < 0) - /* Invalid designation sequence. Just ignore. */ - break; - } - else - /* Invalid designation sequence. Just ignore it. */ - break; - } - else if (c == 'N' || c == 'O') + if (c == 'N' || c == 'O') { /* ESC for SS2 or SS3. */ single_shifting = 1; rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; - break; } else if (c == '1') { @@ -3048,36 +3014,66 @@ detect_coding_iso_2022 (struct coding_system *coding, { /* ESC for start/end composition. */ composition_count = 0; - break; } else { - /* Invalid escape sequence. Just ignore it. */ - break; - } + if (c >= '(' && c <= '/') + { + /* Designation sequence for a charset of dimension 1. */ + ONE_MORE_BYTE (c1); + if (c1 < ' ' || c1 >= 0x80 + || (id = iso_charset_table[0][c >= ','][c1]) < 0) + /* Invalid designation sequence. Just ignore. */ + break; + } + else if (c == '$') + { + /* Designation sequence for a charset of dimension 2. */ + ONE_MORE_BYTE (c); + if (c >= '@' && c <= 'B') + /* Designation for JISX0208.1978, GB2312, or JISX0208. */ + id = iso_charset_table[1][0][c]; + else if (c >= '(' && c <= '/') + { + ONE_MORE_BYTE (c1); + if (c1 < ' ' || c1 >= 0x80 + || (id = iso_charset_table[1][c >= ','][c1]) < 0) + /* Invalid designation sequence. Just ignore. */ + break; + } + else + /* Invalid designation sequence. Just ignore it. */ + break; + } + else + { + /* Invalid escape sequence. Just ignore it. */ + break; + } - /* We found a valid designation sequence for CHARSET. */ - rejected |= CATEGORY_MASK_ISO_8BIT; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], - id)) - found |= CATEGORY_MASK_ISO_7; - else - rejected |= CATEGORY_MASK_ISO_7; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], - id)) - found |= CATEGORY_MASK_ISO_7_TIGHT; - else - rejected |= CATEGORY_MASK_ISO_7_TIGHT; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], - id)) - found |= CATEGORY_MASK_ISO_7_ELSE; - else - rejected |= CATEGORY_MASK_ISO_7_ELSE; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], - id)) - found |= CATEGORY_MASK_ISO_8_ELSE; - else - rejected |= CATEGORY_MASK_ISO_8_ELSE; + /* We found a valid designation sequence for CHARSET. */ + rejected |= CATEGORY_MASK_ISO_8BIT; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], + id)) + found |= CATEGORY_MASK_ISO_7; + else + rejected |= CATEGORY_MASK_ISO_7; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], + id)) + found |= CATEGORY_MASK_ISO_7_TIGHT; + else + rejected |= CATEGORY_MASK_ISO_7_TIGHT; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], + id)) + found |= CATEGORY_MASK_ISO_7_ELSE; + else + rejected |= CATEGORY_MASK_ISO_7_ELSE; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], + id)) + found |= CATEGORY_MASK_ISO_8_ELSE; + else + rejected |= CATEGORY_MASK_ISO_8_ELSE; + } break; case ISO_CODE_SO: @@ -3105,13 +3101,32 @@ detect_coding_iso_2022 (struct coding_system *coding, rejected |= CATEGORY_MASK_ISO_7BIT; if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) & CODING_ISO_FLAG_SINGLE_SHIFT) - found |= CATEGORY_MASK_ISO_8_1, single_shifting = 1; + { + found |= CATEGORY_MASK_ISO_8_1; + single_shifting = 1; + } if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2]) & CODING_ISO_FLAG_SINGLE_SHIFT) - found |= CATEGORY_MASK_ISO_8_2, single_shifting = 1; + { + found |= CATEGORY_MASK_ISO_8_2; + single_shifting = 1; + } if (single_shifting) break; - goto check_extra_latin; + check_extra_latin: + if (! VECTORP (Vlatin_extra_code_table) + || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) + { + rejected = CATEGORY_MASK_ISO; + break; + } + if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) + & CODING_ISO_FLAG_LATIN_EXTRA) + found |= CATEGORY_MASK_ISO_8_1; + else + rejected |= CATEGORY_MASK_ISO_8_1; + rejected |= CATEGORY_MASK_ISO_8_2; + break; default: if (c < 0) @@ -3162,20 +3177,6 @@ detect_coding_iso_2022 (struct coding_system *coding, } break; } - check_extra_latin: - single_shifting = 0; - if (! VECTORP (Vlatin_extra_code_table) - || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) - { - rejected = CATEGORY_MASK_ISO; - break; - } - if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) - & CODING_ISO_FLAG_LATIN_EXTRA) - found |= CATEGORY_MASK_ISO_8_1; - else - rejected |= CATEGORY_MASK_ISO_8_1; - rejected |= CATEGORY_MASK_ISO_8_2; } } detect_info->rejected |= CATEGORY_MASK_ISO; -- cgit v1.2.1 From 8abc3f12955673bdb367b2de5556ff66f202d2d0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 22 Mar 2011 09:20:45 -0700 Subject: * coding.c (encode_coding_raw_text): Avoid unnecessary test the first time through the loop, since we know p0 < p1 then. This also avoids a gcc -Wstrict-overflow warning. --- src/coding.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 0c2836c19f6..0596d16bf46 100644 --- a/src/coding.c +++ b/src/coding.c @@ -5266,11 +5266,12 @@ encode_coding_raw_text (struct coding_system *coding) unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str; CHAR_STRING_ADVANCE (c, p1); - while (p0 < p1) + do { EMIT_ONE_BYTE (*p0); p0++; } + while (p0 < p1); } } else -- cgit v1.2.1 From c5101a77a4066d979698d356c3a9c7f387007359 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 26 Mar 2011 19:12:36 -0700 Subject: Variadic C functions now count arguments with size_t, not int. --- src/coding.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 0596d16bf46..a93a9a4d0e4 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9300,7 +9300,7 @@ function to call for FILENAME, that function should examine the contents of BUFFER instead of reading the file. usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) - (int nargs, Lisp_Object *args) + (size_t nargs, Lisp_Object *args) { Lisp_Object operation, target_idx, target, val; register Lisp_Object chain; @@ -9309,17 +9309,17 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) error ("Too few arguments"); operation = args[0]; if (!SYMBOLP (operation) - || !INTEGERP (target_idx = Fget (operation, Qtarget_idx))) + || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) error ("Invalid first argument"); - if (nargs < 1 + XINT (target_idx)) + if (nargs < 1 + XFASTINT (target_idx)) error ("Too few arguments for operation: %s", SDATA (SYMBOL_NAME (operation))); - target = args[XINT (target_idx) + 1]; + target = args[XFASTINT (target_idx) + 1]; if (!(STRINGP (target) || (EQ (operation, Qinsert_file_contents) && CONSP (target) && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) - error ("Invalid %dth argument", XINT (target_idx) + 1); + error ("Invalid %dth argument", XFASTINT (target_idx) + 1); if (CONSP (target)) target = XCAR (target); @@ -9376,9 +9376,9 @@ If multiple coding systems belong to the same category, all but the first one are ignored. usage: (set-coding-system-priority &rest coding-systems) */) - (int nargs, Lisp_Object *args) + (size_t nargs, Lisp_Object *args) { - int i, j; + size_t i, j; int changed[coding_category_max]; enum coding_category priorities[coding_category_max]; @@ -9421,7 +9421,7 @@ usage: (set-coding-system-priority &rest coding-systems) */) /* Update `coding-category-list'. */ Vcoding_category_list = Qnil; - for (i = coding_category_max - 1; i >= 0; i--) + for (i = coding_category_max; i-- > 0; ) Vcoding_category_list = Fcons (AREF (Vcoding_category_table, priorities[i]), Vcoding_category_list); @@ -9482,7 +9482,7 @@ DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, Sdefine_coding_system_internal, coding_arg_max, MANY, 0, doc: /* For internal use only. usage: (define-coding-system-internal ...) */) - (int nargs, Lisp_Object *args) + (size_t nargs, Lisp_Object *args) { Lisp_Object name; Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ -- cgit v1.2.1 From 461c2ab9a5a244ec9a1b253d07c1a8bdfbd8c573 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Tue, 29 Mar 2011 00:41:01 +0200 Subject: src/*.c: Remove some additional unused parameters. * lisp.h (multibyte_char_to_unibyte): * character.c (multibyte_char_to_unibyte): Remove parameter `rev_tbl', unused since 2002-03-01T01:16:34Z!handa@m17n.org and 2008-02-01T16:01:31Z!miles@gnu.org. * character.h (CHAR_TO_BYTE8): * cmds.c (internal_self_insert): * editfns.c (general_insert_function): * keymap.c (push_key_description): * search.c (Freplace_match): * xdisp.c (message_dolog, set_message_1): All callers changed. * coding.c (encode_designation_at_bol): Remove parameter `charbuf_end', unused since 2002-03-01T01:17:24Z!handa@m17n.org and 2008-02-01T16:01:31Z!miles@gnu.org. All callers changed. --- src/coding.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 0596d16bf46..fd812148a26 100644 --- a/src/coding.c +++ b/src/coding.c @@ -853,8 +853,7 @@ static unsigned char *alloc_destination (struct coding_system *, EMACS_INT, unsigned char *); static void setup_iso_safe_charsets (Lisp_Object); static unsigned char *encode_designation_at_bol (struct coding_system *, - int *, int *, - unsigned char *); + int *, unsigned char *); static int detect_eol (const unsigned char *, EMACS_INT, enum coding_category); static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); @@ -4299,7 +4298,7 @@ encode_invocation_designation (struct charset *charset, static unsigned char * encode_designation_at_bol (struct coding_system *coding, int *charbuf, - int *charbuf_end, unsigned char *dst) + unsigned char *dst) { struct charset *charset; /* Table of charsets to be designated to each graphic register. */ @@ -4390,7 +4389,7 @@ encode_coding_iso_2022 (struct coding_system *coding) unsigned char *dst_prev = dst; /* We have to produce designation sequences if any now. */ - dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); + dst = encode_designation_at_bol (coding, charbuf, dst); bol_designation = 0; /* We are sure that designation sequences are all ASCII bytes. */ produced_chars += dst - dst_prev; -- cgit v1.2.1 From 66ebf9838b3b7744bcf2ad63d62e9cd6c7690066 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 1 Apr 2011 10:20:24 -0700 Subject: * coding.c: Remove vars that are set but not used. (DECODE_COMPOSITION_RULE): Remove 2nd arg, which is unused. All callers changed. (decode_coding_utf_8, decode_coding_utf_16 decode_coding_emacs_mule): (decode_coding_iso_2022, encode_coding_sjis, encode_coding_big5): (decode_coding_charset): Remove vars that are set but not used. --- src/coding.c | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 9e28a1c9f9b..b7e8154107c 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1296,13 +1296,10 @@ decode_coding_utf_8 (struct coding_system *coding) int consumed_chars = 0, consumed_chars_base = 0; int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); - Lisp_Object attr, charset_list; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; - CODING_GET_INFO (coding, attr, charset_list); - if (bom != utf_without_bom) { int c1, c2, c3; @@ -1610,13 +1607,10 @@ decode_coding_utf_16 (struct coding_system *coding) enum utf_bom_type bom = CODING_UTF_16_BOM (coding); enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); int surrogate = CODING_UTF_16_SURROGATE (coding); - Lisp_Object attr, charset_list; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr1 = -1, byte_after_cr2 = -1; - CODING_GET_INFO (coding, attr, charset_list); - if (bom == utf_with_bom) { int c, c1, c2; @@ -1736,11 +1730,8 @@ encode_coding_utf_16 (struct coding_system *coding) enum utf_bom_type bom = CODING_UTF_16_BOM (coding); int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; int produced_chars = 0; - Lisp_Object attrs, charset_list; int c; - CODING_GET_INFO (coding, attrs, charset_list); - if (bom != utf_without_bom) { ASSURE_DESTINATION (safe_room); @@ -2342,7 +2333,6 @@ decode_coding_emacs_mule (struct coding_system *coding) = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); int consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; - Lisp_Object attrs, charset_list; int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; @@ -2351,8 +2341,6 @@ decode_coding_emacs_mule (struct coding_system *coding) int byte_after_cr = -1; struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; - CODING_GET_INFO (coding, attrs, charset_list); - if (cmp_status->state != COMPOSING_NO) { int i; @@ -3265,11 +3253,10 @@ detect_coding_iso_2022 (struct coding_system *coding, */ /* Decode a composition rule C1 and maybe one more byte from the - source, and set RULE to the encoded composition rule, NBYTES to the - length of the composition rule. If the rule is invalid, set RULE - to some negative value. */ + source, and set RULE to the encoded composition rule. If the rule + is invalid, set RULE to some negative value. */ -#define DECODE_COMPOSITION_RULE(rule, nbytes) \ +#define DECODE_COMPOSITION_RULE(rule) \ do { \ rule = c1 - 32; \ if (rule < 0) \ @@ -3281,7 +3268,6 @@ detect_coding_iso_2022 (struct coding_system *coding, if (gref == 4) gref = 10; \ if (nref == 4) nref = 10; \ rule = COMPOSITION_ENCODE_RULE (gref, nref); \ - nbytes = 1; \ } \ else /* new format (after ver.21) */ \ { \ @@ -3291,7 +3277,6 @@ detect_coding_iso_2022 (struct coding_system *coding, rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ if (rule >= 0) \ rule += 0x100; /* to destinguish it from the old format */ \ - nbytes = 2; \ } \ } while (0) @@ -3476,7 +3461,7 @@ decode_coding_iso_2022 (struct coding_system *coding) struct charset *charset; int c; struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); - Lisp_Object attrs, charset_list; + Lisp_Object attrs = CODING_ID_ATTRS (coding->id); int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; @@ -3485,10 +3470,7 @@ decode_coding_iso_2022 (struct coding_system *coding) int byte_after_cr = -1; int i; - CODING_GET_INFO (coding, attrs, charset_list); setup_iso_safe_charsets (attrs); - /* Charset list may have been changed. */ - charset_list = CODING_ATTR_CHARSET_LIST (attrs); coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); if (cmp_status->state != COMPOSING_NO) @@ -3558,9 +3540,9 @@ decode_coding_iso_2022 (struct coding_system *coding) || cmp_status->state == COMPOSING_COMPONENT_RULE) && c1 != ISO_CODE_ESC) { - int rule, nbytes; + int rule; - DECODE_COMPOSITION_RULE (rule, nbytes); + DECODE_COMPOSITION_RULE (rule); if (rule < 0) goto invalid_code; STORE_COMPOSITION_RULE (rule); @@ -4878,13 +4860,12 @@ encode_coding_sjis (struct coding_system *coding) int produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; - struct charset *charset_roman, *charset_kanji, *charset_kana; + struct charset *charset_kanji, *charset_kana; struct charset *charset_kanji2; int c; CODING_GET_INFO (coding, attrs, charset_list); - val = charset_list; - charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); + val = XCDR (charset_list); charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); @@ -4970,12 +4951,11 @@ encode_coding_big5 (struct coding_system *coding) int produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; - struct charset *charset_roman, *charset_big5; + struct charset *charset_big5; int c; CODING_GET_INFO (coding, attrs, charset_list); - val = charset_list; - charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); + val = XCDR (charset_list); charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); @@ -5433,7 +5413,8 @@ decode_coding_charset (struct coding_system *coding) = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); int consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; - Lisp_Object attrs, charset_list, valids; + Lisp_Object attrs = CODING_ID_ATTRS (coding->id); + Lisp_Object valids; int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; @@ -5441,7 +5422,6 @@ decode_coding_charset (struct coding_system *coding) !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; - CODING_GET_INFO (coding, attrs, charset_list); valids = AREF (attrs, coding_attr_charset_valids); while (1) -- cgit v1.2.1 From b25d760e185c85e190402eddd0d756ddc014a58c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 4 Apr 2011 23:24:54 -0700 Subject: * coding.c (EMIT_ONE_BYTE, EMIT_TWO_BYTES): Use unsigned, not int. This avoids several warnings with gcc -Wstrict-overflow. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index b7e8154107c..6e5d0655258 100644 --- a/src/coding.c +++ b/src/coding.c @@ -753,7 +753,7 @@ static struct coding_system coding_categories[coding_category_max]; produced_chars++; \ if (multibytep) \ { \ - int ch = (c); \ + unsigned ch = (c); \ if (ch >= 0x80) \ ch = BYTE8_TO_CHAR (ch); \ CHAR_STRING_ADVANCE (ch, dst); \ @@ -770,7 +770,7 @@ static struct coding_system coding_categories[coding_category_max]; produced_chars += 2; \ if (multibytep) \ { \ - int ch; \ + unsigned ch; \ \ ch = (c1); \ if (ch >= 0x80) \ -- cgit v1.2.1 From d5efd1d1b54595db795d6fddb32404cc74923d77 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 4 Apr 2011 23:41:53 -0700 Subject: * coding.c (DECODE_COMPOSITION_RULE): If the rule is invalid, goto invalid_code directly, rather than having caller test rule sign. This avoids some unnecessary tests. * composite.h (COMPOSITION_ENCODE_RULE_VALID): New macro. (COMPOSITION_ENCODE_RULE): Arguments now must be valid. This affects only one use, in DECODE_COMPOSITION_RULE, which is changed. --- src/coding.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 6e5d0655258..555c29cbdf3 100644 --- a/src/coding.c +++ b/src/coding.c @@ -3254,13 +3254,13 @@ detect_coding_iso_2022 (struct coding_system *coding, /* Decode a composition rule C1 and maybe one more byte from the source, and set RULE to the encoded composition rule. If the rule - is invalid, set RULE to some negative value. */ + is invalid, goto invalid_code. */ #define DECODE_COMPOSITION_RULE(rule) \ do { \ rule = c1 - 32; \ if (rule < 0) \ - break; \ + goto invalid_code; \ if (rule < 81) /* old format (before ver.21) */ \ { \ int gref = (rule) / 9; \ @@ -3274,9 +3274,10 @@ detect_coding_iso_2022 (struct coding_system *coding, int b; \ \ ONE_MORE_BYTE (b); \ + if (! COMPOSITION_ENCODE_RULE_VALID (rule - 81, b - 32)) \ + goto invalid_code; \ rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ - if (rule >= 0) \ - rule += 0x100; /* to destinguish it from the old format */ \ + rule += 0x100; /* Distinguish it from the old format. */ \ } \ } while (0) @@ -3543,8 +3544,6 @@ decode_coding_iso_2022 (struct coding_system *coding) int rule; DECODE_COMPOSITION_RULE (rule); - if (rule < 0) - goto invalid_code; STORE_COMPOSITION_RULE (rule); continue; } -- cgit v1.2.1 From 7e2cac200108a4626573c4a8de851560c1fee456 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 6 Apr 2011 16:02:23 -0700 Subject: * coding.c (Fdecode_sjis_char): Don't assume CODE fits in int. --- src/coding.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 555c29cbdf3..798e5c533f6 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9023,7 +9023,7 @@ Return the corresponding character. */) { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; - int c; + EMACS_INT c; CHECK_NATNUM (code); c = XFASTINT (code); @@ -9048,7 +9048,8 @@ Return the corresponding character. */) } else { - int c1 = c >> 8, c2 = c & 0xFF; + EMACS_INT c1 = c >> 8; + int c2 = c & 0xFF; if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) -- cgit v1.2.1 From 5fdb398c4b75b0c834aff7132f90b0ce5317a25a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 6 Apr 2011 20:34:05 -0700 Subject: error: Print 32- and 64-bit integers portably (Bug#8435). Without this change, on typical 64-bit hosts error ("...%d...", N) was used to print both 32- and 64-bit integers N, which relied on undefined behavior. * lisp.h, src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h (pEd): New macro. * lisp.h (error, verror): Mark as printf-like functions. * eval.c (verror): Use vsnprintf, not doprnt, to do the real work. Report overflow in size calculations when allocating printf buffer. Do not truncate output string at its first null byte. * xdisp.c (vmessage): Use vsnprintf, not doprnt, to do the real work. Truncate the output at a character boundary, since vsnprintf does not do that. * charset.c (check_iso_charset_parameter): Convert internal character to string before calling 'error', since %c now has the printf meaning. * coding.c (Fdecode_sjis_char, Fdecode_big5_char): Avoid int overflow when computing char to be passed to 'error'. Do not pass Lisp_Object to 'error'; pass the integer instead. * nsfns.m (Fns_do_applescript): Use int, not long, since it's formatted with plain %d. --- src/coding.c | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 798e5c533f6..f099605c774 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9023,14 +9023,15 @@ Return the corresponding character. */) { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; - EMACS_INT c; + EMACS_INT ch; + int c; CHECK_NATNUM (code); - c = XFASTINT (code); + ch = XFASTINT (code); CHECK_CODING_SYSTEM_GET_SPEC (Vsjis_coding_system, spec); attrs = AREF (spec, 0); - if (ASCII_BYTE_P (c) + if (ASCII_BYTE_P (ch) && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) return code; @@ -9039,27 +9040,31 @@ Return the corresponding character. */) charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))); - if (c <= 0x7F) - charset = charset_roman; - else if (c >= 0xA0 && c < 0xDF) + if (ch <= 0x7F) + { + c = ch; + charset = charset_roman; + } + else if (ch >= 0xA0 && ch < 0xDF) { + c = ch - 0x80; charset = charset_kana; - c -= 0x80; } else { - EMACS_INT c1 = c >> 8; - int c2 = c & 0xFF; + EMACS_INT c1 = ch >> 8; + int c2 = ch & 0xFF; if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); + c = ch; SJIS_TO_JIS (c); charset = charset_kanji; } c = DECODE_CHAR (charset, c); if (c < 0) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); return make_number (c); } @@ -9099,14 +9104,15 @@ Return the corresponding character. */) { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_big5, *charset; + EMACS_INT ch; int c; CHECK_NATNUM (code); - c = XFASTINT (code); + ch = XFASTINT (code); CHECK_CODING_SYSTEM_GET_SPEC (Vbig5_coding_system, spec); attrs = AREF (spec, 0); - if (ASCII_BYTE_P (c) + if (ASCII_BYTE_P (ch) && ! NILP (CODING_ATTR_ASCII_COMPAT (attrs))) return code; @@ -9114,19 +9120,24 @@ Return the corresponding character. */) charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); - if (c <= 0x7F) - charset = charset_roman; + if (ch <= 0x7F) + { + c = ch; + charset = charset_roman; + } else { - int b1 = c >> 8, b2 = c & 0x7F; + EMACS_INT b1 = ch >> 8; + int b2 = ch & 0x7F; if (b1 < 0xA1 || b1 > 0xFE || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); + c = ch; charset = charset_big5; } - c = DECODE_CHAR (charset, (unsigned )c); + c = DECODE_CHAR (charset, c); if (c < 0) - error ("Invalid code: %d", code); + error ("Invalid code: %"pEd, ch); return make_number (c); } @@ -9298,7 +9309,7 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) || (EQ (operation, Qinsert_file_contents) && CONSP (target) && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) - error ("Invalid %dth argument", XFASTINT (target_idx) + 1); + error ("Invalid %"pEd"th argument", XFASTINT (target_idx) + 1); if (CONSP (target)) target = XCAR (target); @@ -9774,7 +9785,7 @@ usage: (define-coding-system-internal ...) */) CHECK_CHARSET_GET_ID (tmp1, id); CHECK_NATNUM_CDR (val); if (XINT (XCDR (val)) >= 4) - error ("Invalid graphic register number: %d", XINT (XCDR (val))); + error ("Invalid graphic register number: %"pEd, XINT (XCDR (val))); XSETCAR (val, make_number (id)); } -- cgit v1.2.1 From a53e2e898b96c8024de5a1a413826a6a59dd6b54 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 9 Apr 2011 19:35:19 +0300 Subject: Replace some uses of `int' with EMACS_INT. src/search.c (string_match_1, fast_string_match) (fast_c_string_match_ignore_case, fast_string_match_ignore_case) (scan_buffer, find_next_newline_no_quit) (find_before_next_newline, search_command, Freplace_match) (Fmatch_data): Make some `int' variables be EMACS_INT. src/xdisp.c (display_count_lines): 3rd argument and return value now EMACS_INT. All callers changed. (pint2hrstr): Last argument is now EMACS_INT. src/coding.c (detect_coding_utf_8, detect_coding_emacs_mule) (detect_coding_iso_2022, detect_coding_sjis, detect_coding_big5) (detect_coding_ccl, detect_coding_charset, decode_coding_utf_8) (decode_coding_utf_16, decode_coding_emacs_mule) (decode_coding_iso_2022, decode_coding_sjis, decode_coding_big5) (decode_coding_ccl, decode_coding_charset) : Declare EMACS_INT. (decode_coding_iso_2022, decode_coding_emacs_mule) (decode_coding_sjis, decode_coding_big5, decode_coding_charset) : Declare EMACS_INT. (encode_coding_utf_8, encode_coding_utf_16) (encode_coding_emacs_mule, encode_invocation_designation) (encode_designation_at_bol, encode_coding_iso_2022) (encode_coding_sjis, encode_coding_big5, encode_coding_ccl) (encode_coding_raw_text, encode_coding_charset) : Declare EMACS_INT. (ASSURE_DESTINATION): Declare more_bytes EMACS_INT. (encode_invocation_designation): Last argument P_NCHARS is now EMACS_INT. (decode_eol): Declare pos_byte, pos, and pos_end EMACS_INT. (produce_chars): from_nchars and to_nchars are now EMACS_INT. src/coding.h (struct coding_system) : Declare EMACS_INT. All users changed. src/ccl.c (Fccl_execute_on_string): Declare some variables EMACS_INT. --- src/coding.c | 95 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 47 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 555c29cbdf3..a2e90e631d1 100644 --- a/src/coding.c +++ b/src/coding.c @@ -159,7 +159,7 @@ detect_coding_XXX (struct coding_system *coding, const unsigned char *src = coding->source; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; ...; @@ -266,7 +266,7 @@ encode_coding_XXX (struct coding_system *coding) unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; - int produced_chars = 0; + EMACS_INT produced_chars = 0; for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) { @@ -943,7 +943,7 @@ record_conversion_result (struct coding_system *coding, do { \ if (dst + (bytes) >= dst_end) \ { \ - int more_bytes = charbuf_end - charbuf + (bytes); \ + EMACS_INT more_bytes = charbuf_end - charbuf + (bytes); \ \ dst = alloc_destination (coding, more_bytes, dst); \ dst_end = coding->destination + coding->dst_bytes; \ @@ -1208,7 +1208,7 @@ detect_coding_utf_8 (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int bom_found = 0; int found = 0; @@ -1293,7 +1293,7 @@ decode_coding_utf_8 (struct coding_system *coding) const unsigned char *src_base; int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; - int consumed_chars = 0, consumed_chars_base = 0; + EMACS_INT consumed_chars = 0, consumed_chars_base = 0; int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); int eol_dos = @@ -1444,7 +1444,7 @@ encode_coding_utf_8 (struct coding_system *coding) int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int c; if (CODING_UTF_8_BOM (coding) == utf_with_bom) @@ -1602,7 +1602,7 @@ decode_coding_utf_16 (struct coding_system *coding) int *charbuf = coding->charbuf + coding->charbuf_used; /* We may produces at most 3 chars in one loop. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; - int consumed_chars = 0, consumed_chars_base = 0; + EMACS_INT consumed_chars = 0, consumed_chars_base = 0; int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_16_BOM (coding); enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); @@ -1729,7 +1729,7 @@ encode_coding_utf_16 (struct coding_system *coding) int safe_room = 8; enum utf_bom_type bom = CODING_UTF_16_BOM (coding); int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int c; if (bom != utf_without_bom) @@ -1863,7 +1863,7 @@ detect_coding_emacs_mule (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int c; int found = 0; @@ -2331,10 +2331,10 @@ decode_coding_emacs_mule (struct coding_system *coding) loop and one more charset annotation at the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -2585,7 +2585,7 @@ encode_coding_emacs_mule (struct coding_system *coding) unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 8; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list; int c; int preferred_charset_id = -1; @@ -2943,7 +2943,7 @@ detect_coding_iso_2022 (struct coding_system *coding, int single_shifting = 0; int id; int c, c1; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int i; int rejected = 0; int found = 0; @@ -3453,7 +3453,7 @@ decode_coding_iso_2022 (struct coding_system *coding) loop and one more charset annotation at the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; /* Charsets invoked to graphic plane 0 and 1 respectively. */ int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); @@ -3463,8 +3463,8 @@ decode_coding_iso_2022 (struct coding_system *coding) int c; struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); Lisp_Object attrs = CODING_ID_ATTRS (coding->id); - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -4190,10 +4190,10 @@ decode_coding_iso_2022 (struct coding_system *coding) static unsigned char * encode_invocation_designation (struct charset *charset, struct coding_system *coding, - unsigned char *dst, int *p_nchars) + unsigned char *dst, EMACS_INT *p_nchars) { int multibytep = coding->dst_multibyte; - int produced_chars = *p_nchars; + EMACS_INT produced_chars = *p_nchars; int reg; /* graphic register number */ int id = CHARSET_ID (charset); @@ -4285,7 +4285,7 @@ encode_designation_at_bol (struct coding_system *coding, int *charbuf, /* Table of charsets to be designated to each graphic register. */ int r[4]; int c, found = 0, reg; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int multibytep = coding->dst_multibyte; Lisp_Object attrs; Lisp_Object charset_list; @@ -4340,7 +4340,7 @@ encode_coding_iso_2022 (struct coding_system *coding) int bol_designation = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL && CODING_ISO_BOL (coding)); - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, eol_type, charset_list; int ascii_compatible; int c; @@ -4528,7 +4528,7 @@ detect_coding_sjis (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; int c; Lisp_Object attrs, charset_list; @@ -4585,7 +4585,7 @@ detect_coding_big5 (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; int c; @@ -4636,13 +4636,13 @@ decode_coding_sjis (struct coding_system *coding) the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; struct charset *charset_roman, *charset_kanji, *charset_kana; struct charset *charset_kanji2; Lisp_Object attrs, charset_list, val; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -4754,12 +4754,12 @@ decode_coding_big5 (struct coding_system *coding) the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; struct charset *charset_roman, *charset_big5; Lisp_Object attrs, charset_list, val; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -4856,7 +4856,7 @@ encode_coding_sjis (struct coding_system *coding) unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 4; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; struct charset *charset_kanji, *charset_kana; @@ -4947,7 +4947,7 @@ encode_coding_big5 (struct coding_system *coding) unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 4; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; struct charset *charset_big5; @@ -5022,10 +5022,10 @@ detect_coding_ccl (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; unsigned char *valids; - int head_ascii = coding->head_ascii; + EMACS_INT head_ascii = coding->head_ascii; Lisp_Object attrs; detect_info->checked |= CATEGORY_MASK_CCL; @@ -5062,7 +5062,7 @@ decode_coding_ccl (struct coding_system *coding) const unsigned char *src_end = coding->source + coding->src_bytes; int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int multibytep = coding->src_multibyte; struct ccl_program *ccl = &coding->spec.ccl->ccl; int source_charbuf[1024]; @@ -5134,7 +5134,8 @@ encode_coding_ccl (struct coding_system *coding) unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int destination_charbuf[1024]; - int i, produced_chars = 0; + EMACS_INT produced_chars = 0; + int i; Lisp_Object attrs, charset_list; CODING_GET_INFO (coding, attrs, charset_list); @@ -5220,7 +5221,7 @@ encode_coding_raw_text (struct coding_system *coding) int *charbuf_end = coding->charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int c; if (multibytep) @@ -5303,10 +5304,10 @@ detect_coding_charset (struct coding_system *coding, const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; Lisp_Object attrs, valids, name; int found = 0; - int head_ascii = coding->head_ascii; + EMACS_INT head_ascii = coding->head_ascii; int check_latin_extra = 0; detect_info->checked |= CATEGORY_MASK_CHARSET; @@ -5410,12 +5411,12 @@ decode_coding_charset (struct coding_system *coding) the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; Lisp_Object attrs = CODING_ID_ATTRS (coding->id); Lisp_Object valids; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -5536,7 +5537,7 @@ encode_coding_charset (struct coding_system *coding) unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = MAX_MULTIBYTE_LENGTH; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list; int ascii_compatible; int c; @@ -6444,7 +6445,7 @@ decode_eol (struct coding_system *coding) } else if (EQ (eol_type, Qdos)) { - int n = 0; + EMACS_INT n = 0; if (NILP (coding->dst_object)) { @@ -6459,9 +6460,9 @@ decode_eol (struct coding_system *coding) } else { - int pos_byte = coding->dst_pos_byte; - int pos = coding->dst_pos; - int pos_end = pos + coding->produced_char - 1; + EMACS_INT pos_byte = coding->dst_pos_byte; + EMACS_INT pos = coding->dst_pos; + EMACS_INT pos_end = pos + coding->produced_char - 1; while (pos < pos_end) { @@ -6646,7 +6647,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, if (c >= 0) { - int from_nchars = 1, to_nchars = 1; + EMACS_INT from_nchars = 1, to_nchars = 1; Lisp_Object trans = Qnil; LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); -- cgit v1.2.1 From 16a97296c05ec9d5bb4ffeae9dce90fc63f578ed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 18:41:15 -0700 Subject: Make Emacs functions such as Fatom 'static' by default. This makes it easier for human readers (and static analyzers) to see whether these functions can be called from other modules. DEFUN now defines a static function. To make the function external so that it can be used in other C modules, use the new macro DEFUE. * lisp.h (DEFINE_FUNC): New macro, with the old contents of DEFUN. (DEFUN): Rewrite in terms of DEFINE_FUNC. It now generates a static function definition. Use DEFUE if you want an extern one. (DEFUE, INFUN): New macros. (Funibyte_char_to_multibyte, Fsyntax_table_p, Finit_image_library): (Feval_region, Fbacktrace, Ffetch_bytecode, Fswitch_to_buffer): (Ffile_executable_p, Fmake_symbolic_link, Fcommand_execute): (Fget_process, Fdocumentation_property, Fbyte_code, Ffile_attributes): Remove decls, since these functions are now static. (Funintern, Fget_internal_run_time): New decls, since these functions were already external. * alloc.c, buffer.c, callint.c, callproc.c, casefiddle.c, casetab.c: * ccl.c, character.c, chartab.c, cmds.c, coding.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, floatfns.c: * fns.c, font.c, fontset.c, frame.c, image.c, indent.c: * keyboard.c, keymap.c, lread.c: * macros.c, marker.c, menu.c, minibuf.c, print.c, process.c, search.c: * syntax.c, term.c, terminal.c, textprop.c, undo.c: * window.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xsettings.c: Mark functions with DEFUE instead of DEFUN, if they are used in other modules. * buffer.c (Fset_buffer_major_mode, Fdelete_overlay): New forward decls for now-static functions. * buffer.h (Fdelete_overlay): Remove decl. * callproc.c (Fgetenv_internal): Mark as internal. * composite.c (Fremove_list_of_text_properties): Remove decl. (Fcomposition_get_gstring): New forward static decl. * composite.h (Fcomposite_get_gstring): Remove decl. * dired.c (Ffile_attributes): New forward static decl. * doc.c (Fdocumntation_property): New forward static decl. * eval.c (Ffetch_bytecode): New forward static decl. (Funintern): Remove extern decl; now in .h file where it belongs. * fileio.c (Fmake_symbolic_link): New forward static decl. * image.c (Finit_image_library): New forward static decl. * insdel.c (Fcombine_after_change_execute): Make forward decl static. * intervals.h (Fprevious_property_change): (Fremove_list_of_text_properties): Remove decls. * keyboard.c (Fthis_command_keys): Remove decl. (Fcommand_execute): New forward static decl. * keymap.c (Flookup_key): New forward static decl. (Fcopy_keymap): Now static. * keymap.h (Flookup_key): Remove decl. * process.c (Fget_process): New forward static decl. (Fprocess_datagram_address): Mark as internal. * syntax.c (Fsyntax_table_p): New forward static decl. (skip_chars): Remove duplicate decl. * textprop.c (Fprevious_property_change): New forward static decl. * window.c (Fset_window_fringes, Fset_window_scroll_bars): Now internal. (Fset_window_margins, Fset_window_vscroll): New forward static decls. * window.h (Fset_window_vscroll, Fset_window_margins): Remove decls. --- src/coding.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 711ada59c85..13fcb7fb8a5 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7991,7 +7991,7 @@ preferred_coding_system (void) #ifdef emacs /*** 8. Emacs Lisp library functions ***/ -DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, +DEFUE ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, doc: /* Return t if OBJECT is nil or a coding-system. See the documentation of `define-coding-system' for information about coding-system objects. */) @@ -8006,7 +8006,7 @@ about coding-system objects. */) return Qt; } -DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, +DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system, Sread_non_nil_coding_system, 1, 1, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) (Lisp_Object prompt) @@ -8021,7 +8021,7 @@ DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, return (Fintern (val, Qnil)); } -DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, +DEFUE ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. Ignores case when completing coding systems (all Emacs coding systems @@ -8041,7 +8041,7 @@ are lower-case). */) return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); } -DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, +DEFUE ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, 1, 1, 0, doc: /* Check validity of CODING-SYSTEM. If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. @@ -8976,7 +8976,7 @@ code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, } -DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, +DEFUE ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 2, 4, 0, doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. @@ -9250,7 +9250,7 @@ DEFUN ("keyboard-coding-system", } -DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, +DEFUE ("find-operation-coding-system", Ffind_operation_coding_system, Sfind_operation_coding_system, 1, MANY, 0, doc: /* Choose a coding system for an operation based on the target name. The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM). @@ -10093,7 +10093,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, return Qnil; } -DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, +DEFUE ("coding-system-base", Fcoding_system_base, Scoding_system_base, 1, 1, 0, doc: /* Return the base of CODING-SYSTEM. Any alias or subsidiary coding system is not a base coding system. */) @@ -10136,7 +10136,7 @@ DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, return AREF (spec, 1); } -DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, +DEFUE ("coding-system-eol-type", Fcoding_system_eol_type, Scoding_system_eol_type, 1, 1, 0, doc: /* Return eol-type of CODING-SYSTEM. An eol-type is an integer 0, 1, 2, or a vector of coding systems. -- cgit v1.2.1 From 955cbe7b1720f09b2991b7d981147d9cc79d52e3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 20:39:45 -0700 Subject: Declare Lisp_Object Q* variables to be 'static' if not exproted. This makes it easier for human readers (and static analyzers) to see whether these variables are used from other modules. * alloc.c, buffer.c, bytecode.c, callint.c, casetab.c, category.c: * ccl.c, character.c, charset.c, cmds.c, coding.c, composite.c: * data.c, dbusbind.c, dired.c, editfns.c, eval.c, fileio.c, fns.c: * font.c, frame.c, fringe.c, ftfont.c, image.c, keyboard.c, keymap.c: * lread.c, macros.c, minibuf.c, print.c, process.c, search.c: * sound.c, syntax.c, textprop.c, window.c, xdisp.c, xfaces.c, xfns.c: * xmenu.c, xselect.c: Declare Q* vars static if they are not used in other modules. * ccl.h, character.h, charset.h, coding.h, composite.h, font.h: * frame.h, intervals.h, keyboard.h, lisp.h, process.h, syntax.h: Remove decls of unexported vars. * keyboard.h (EVENT_HEAD_UNMODIFIED): Remove now-unused macro. --- src/coding.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 13fcb7fb8a5..d2124db73f2 100644 --- a/src/coding.c +++ b/src/coding.c @@ -300,27 +300,30 @@ encode_coding_XXX (struct coding_system *coding) Lisp_Object Vcoding_system_hash_table; -Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type; +static Lisp_Object Qcoding_system, Qeol_type; +static Lisp_Object Qcoding_aliases; Lisp_Object Qunix, Qdos; Lisp_Object Qbuffer_file_coding_system; -Lisp_Object Qpost_read_conversion, Qpre_write_conversion; -Lisp_Object Qdefault_char; +static Lisp_Object Qpost_read_conversion, Qpre_write_conversion; +static Lisp_Object Qdefault_char; Lisp_Object Qno_conversion, Qundecided; -Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5; -Lisp_Object Qbig, Qlittle; -Lisp_Object Qcoding_system_history; -Lisp_Object Qvalid_codes; -Lisp_Object QCcategory, QCmnemonic, QCdefault_char; -Lisp_Object QCdecode_translation_table, QCencode_translation_table; -Lisp_Object QCpost_read_conversion, QCpre_write_conversion; -Lisp_Object QCascii_compatible_p; +Lisp_Object Qcharset, Qutf_8; +static Lisp_Object Qiso_2022; +static Lisp_Object Qutf_16, Qshift_jis, Qbig5; +static Lisp_Object Qbig, Qlittle; +static Lisp_Object Qcoding_system_history; +static Lisp_Object Qvalid_codes; +static Lisp_Object QCcategory, QCmnemonic, QCdefault_char; +static Lisp_Object QCdecode_translation_table, QCencode_translation_table; +static Lisp_Object QCpost_read_conversion, QCpre_write_conversion; +static Lisp_Object QCascii_compatible_p; Lisp_Object Qcall_process, Qcall_process_region; Lisp_Object Qstart_process, Qopen_network_stream; -Lisp_Object Qtarget_idx; +static Lisp_Object Qtarget_idx; -Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; -Lisp_Object Qinterrupted, Qinsufficient_memory; +static Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; +static Lisp_Object Qinterrupted, Qinsufficient_memory; /* If a symbol has this property, evaluate the value to define the symbol as a coding system. */ @@ -351,8 +354,8 @@ struct coding_system safe_terminal_coding; Lisp_Object Qtranslation_table; Lisp_Object Qtranslation_table_id; -Lisp_Object Qtranslation_table_for_decode; -Lisp_Object Qtranslation_table_for_encode; +static Lisp_Object Qtranslation_table_for_decode; +static Lisp_Object Qtranslation_table_for_encode; /* Two special coding systems. */ Lisp_Object Vsjis_coding_system; -- cgit v1.2.1 From 74ab6df507f0f4707a8bd25924fbdba9d1610f4f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 23:58:57 -0700 Subject: * coding.h (coding, code_convert_region, encode_coding_gap): Remove decls. * coding.c (Vsjis_coding_system, Vbig5_coding_system): (iso_code_class, detect_coding, code_convert_region): Now static. (encode_coding_gap): Remove; unused. --- src/coding.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index d2124db73f2..c29713a5c0c 100644 --- a/src/coding.c +++ b/src/coding.c @@ -358,8 +358,8 @@ static Lisp_Object Qtranslation_table_for_decode; static Lisp_Object Qtranslation_table_for_encode; /* Two special coding systems. */ -Lisp_Object Vsjis_coding_system; -Lisp_Object Vbig5_coding_system; +static Lisp_Object Vsjis_coding_system; +static Lisp_Object Vbig5_coding_system; /* ISO2022 section */ @@ -2862,7 +2862,7 @@ encode_coding_emacs_mule (struct coding_system *coding) COMPOSITION_WITH_RULE_ALTCHARS: ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ -enum iso_code_class_type iso_code_class[256]; +static enum iso_code_class_type iso_code_class[256]; #define SAFE_CHARSET_P(coding, id) \ ((id) <= (coding)->max_charset_id \ @@ -6212,7 +6212,7 @@ adjust_coding_eol_type (struct coding_system *coding, int eol_seen) system is detected, update fields of CODING by the detected coding system. */ -void +static void detect_coding (struct coding_system *coding) { const unsigned char *src, *src_end; @@ -7530,30 +7530,6 @@ decode_coding_gap (struct coding_system *coding, return coding->result; } -int -encode_coding_gap (struct coding_system *coding, - EMACS_INT chars, EMACS_INT bytes) -{ - int count = SPECPDL_INDEX (); - - code_conversion_save (0, 0); - - coding->src_object = Fcurrent_buffer (); - coding->src_chars = chars; - coding->src_bytes = bytes; - coding->src_pos = -chars; - coding->src_pos_byte = -bytes; - coding->src_multibyte = chars < bytes; - coding->dst_object = coding->src_object; - coding->dst_pos = PT; - coding->dst_pos_byte = PT_BYTE; - - encode_coding (coding); - - unbind_to (count, Qnil); - return coding->result; -} - /* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in SRC_OBJECT into DST_OBJECT by coding context CODING. @@ -8834,7 +8810,7 @@ is nil. */) } -Lisp_Object +static Lisp_Object code_convert_region (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object dst_object, int encodep, int norecord) -- cgit v1.2.1 From a7ca3326c4740ed3ed118b794d35d235de49f346 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 22:04:02 -0700 Subject: Undo the DEFUN->DEFUE change. --- src/coding.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index c29713a5c0c..b49070e5e16 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7970,7 +7970,7 @@ preferred_coding_system (void) #ifdef emacs /*** 8. Emacs Lisp library functions ***/ -DEFUE ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, +DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, doc: /* Return t if OBJECT is nil or a coding-system. See the documentation of `define-coding-system' for information about coding-system objects. */) @@ -7985,7 +7985,7 @@ about coding-system objects. */) return Qt; } -DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system, +DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, Sread_non_nil_coding_system, 1, 1, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) (Lisp_Object prompt) @@ -8000,7 +8000,7 @@ DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system, return (Fintern (val, Qnil)); } -DEFUE ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, +DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. Ignores case when completing coding systems (all Emacs coding systems @@ -8020,7 +8020,7 @@ are lower-case). */) return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); } -DEFUE ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, +DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, 1, 1, 0, doc: /* Check validity of CODING-SYSTEM. If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. @@ -8955,7 +8955,7 @@ code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, } -DEFUE ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, +DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 2, 4, 0, doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. @@ -9229,7 +9229,7 @@ DEFUN ("keyboard-coding-system", } -DEFUE ("find-operation-coding-system", Ffind_operation_coding_system, +DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, Sfind_operation_coding_system, 1, MANY, 0, doc: /* Choose a coding system for an operation based on the target name. The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM). @@ -10072,7 +10072,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, return Qnil; } -DEFUE ("coding-system-base", Fcoding_system_base, Scoding_system_base, +DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, 1, 1, 0, doc: /* Return the base of CODING-SYSTEM. Any alias or subsidiary coding system is not a base coding system. */) @@ -10115,7 +10115,7 @@ DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, return AREF (spec, 1); } -DEFUE ("coding-system-eol-type", Fcoding_system_eol_type, +DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, Scoding_system_eol_type, 1, 1, 0, doc: /* Return eol-type of CODING-SYSTEM. An eol-type is an integer 0, 1, 2, or a vector of coding systems. -- cgit v1.2.1 From c2982e87d382f0b5c00a65e63716c2b43d342881 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 18 Apr 2011 17:34:42 -0700 Subject: Replace pEd with more-general pI, and fix some printf arg casts. * lisp.h (pI): New macro, generalizing old pEd macro to other conversion specifiers. For example, use "...%"pI"d..." rather than "...%"pEd"...". (pEd): Remove. All uses replaced with similar uses of pI. * src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h: Likewise. * alloc.c (check_pure_size): Don't overflow by converting size to int. * bidi.c (bidi_dump_cached_states): Use pI to avoid cast. * data.c (Fnumber_to_string): Use pI instead of if-then-else-abort. * dbusbind.c (xd_append_arg): Use pI to avoid cast. (Fdbus_method_return_internal, Fdbus_method_error_internal): Likewise. * font.c (font_unparse_xlfd): Avoid potential buffer overrun on 64-bit hosts. (font_unparse_xlfd, font_unparse_fcname): Use pI to avoid casts. * keyboard.c (record_char, modify_event_symbol): Use pI to avoid casts. * print.c (safe_debug_print, print_object): Likewise. (print_object): Don't overflow by converting EMACS_INT or EMACS_UINT to int. Use pI instead of if-then-else-abort. Use %p to avoid casts. * process.c (Fmake_network_process): Use pI to avoid cast. * region-cache.c (pp_cache): Likewise. * xdisp.c (decode_mode_spec): Likewise. * xrdb.c (x_load_resources) [USE_MOTIF]: Use pI to avoid undefined behavior on 64-bit hosts with printf arg. * xselect.c (x_queue_event): Use %p to avoid casts. (x_stop_queuing_selection_requests): Likewise. (x_get_window_property): Don't truncate byte count to an 'int' when tracing. --- src/coding.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index b49070e5e16..38e41e7a99e 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9037,14 +9037,14 @@ Return the corresponding character. */) if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC) - error ("Invalid code: %"pEd, ch); + error ("Invalid code: %"pI"d", ch); c = ch; SJIS_TO_JIS (c); charset = charset_kanji; } c = DECODE_CHAR (charset, c); if (c < 0) - error ("Invalid code: %"pEd, ch); + error ("Invalid code: %"pI"d", ch); return make_number (c); } @@ -9111,13 +9111,13 @@ Return the corresponding character. */) int b2 = ch & 0x7F; if (b1 < 0xA1 || b1 > 0xFE || b2 < 0x40 || (b2 > 0x7E && b2 < 0xA1) || b2 > 0xFE) - error ("Invalid code: %"pEd, ch); + error ("Invalid code: %"pI"d", ch); c = ch; charset = charset_big5; } c = DECODE_CHAR (charset, c); if (c < 0) - error ("Invalid code: %"pEd, ch); + error ("Invalid code: %"pI"d", ch); return make_number (c); } @@ -9289,7 +9289,7 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) || (EQ (operation, Qinsert_file_contents) && CONSP (target) && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) - error ("Invalid %"pEd"th argument", XFASTINT (target_idx) + 1); + error ("Invalid %"pI"dth argument", XFASTINT (target_idx) + 1); if (CONSP (target)) target = XCAR (target); @@ -9765,7 +9765,7 @@ usage: (define-coding-system-internal ...) */) CHECK_CHARSET_GET_ID (tmp1, id); CHECK_NATNUM_CDR (val); if (XINT (XCDR (val)) >= 4) - error ("Invalid graphic register number: %"pEd, XINT (XCDR (val))); + error ("Invalid graphic register number: %"pI"d", XINT (XCDR (val))); XSETCAR (val, make_number (id)); } -- cgit v1.2.1 From e6c3da2065ac72cc4e1a2bef22d367cd75401892 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 23 Apr 2011 13:33:28 +0300 Subject: Fix doprnt so it could be used safely in `verror'. (Bug#8435) src/doprnt.c: Include limits.h. (SIZE_MAX): New macro. (doprnt): Return a size_t value. 2nd arg is now size_t. Many local variables are now size_t instead of int or unsigned. Improve overflow protection. Support `l' modifier for integer conversions. Support %l conversion. Don't assume an EMACS_INT argument for integer conversions and for %c. src/lisp.h (doprnt): Restore prototype. src/makefile.w32-in ($(BLD)/callint.$(O)): Depend on $(SRC)/character.h. src/Makefile.in (base_obj): Add back doprnt.o. src/deps.mk (doprnt.o): Add back prerequisites. (callint.o): Depend on character.h. src/eval.c (internal_lisp_condition_case): Include the handler representation in the error message. (verror): Call doprnt instead of vsnprintf. Fix an off-by-one bug when breaking from the loop. src/xdisp.c (vmessage): Call doprnt instead of vsnprintf. src/callint.c (Fcall_interactively): When displaying error message about invalid control letter, pass the character's codepoint, not a pointer to its multibyte form. Improve display of the character in octal and display also its hex code. src/character.c (char_string): Use %x to display the (unsigned) codepoint of an invalid character, to avoid displaying a bogus negative value. src/font.c (check_otf_features): Pass SDATA of SYMBOL_NAME to `error', not SYMBOL_NAME itself. src/coding.c (Fencode_sjis_char, Fencode_big5_char): Use %c for character arguments to `error'. src/charset.c (check_iso_charset_parameter): Fix incorrect argument to `error' in error message about FINAL_CHAR argument. Make sure FINAL_CHAR is a character, and use %c when it is passed as argument to `error'. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index b49070e5e16..221ada51158 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9071,7 +9071,7 @@ Return the corresponding code in SJIS. */) charset_list = CODING_ATTR_CHARSET_LIST (attrs); charset = char_charset (c, charset_list, &code); if (code == CHARSET_INVALID_CODE (charset)) - error ("Can't encode by shift_jis encoding: %d", c); + error ("Can't encode by shift_jis encoding: %c", c); JIS_TO_SJIS (code); return make_number (code); @@ -9142,7 +9142,7 @@ Return the corresponding character code in Big5. */) charset_list = CODING_ATTR_CHARSET_LIST (attrs); charset = char_charset (c, charset_list, &code); if (code == CHARSET_INVALID_CODE (charset)) - error ("Can't encode by Big5 encoding: %d", c); + error ("Can't encode by Big5 encoding: %c", c); return make_number (code); } -- cgit v1.2.1 From eab3844f965646b62e242aa622754b86d1fd3444 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 25 Apr 2011 00:14:46 -0700 Subject: lisp.h: Fix a problem with aliasing and vector headers. GCC 4.6.0 optimizes based on type-based alias analysis. For example, if b is of type struct buffer * and v of type struct Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size != &v->size, and therefore "v->size = 1; b->size = 2; return v->size;" must therefore return 1. This assumption is incorrect for Emacs, since it type-puns struct Lisp_Vector * with many other types. To fix this problem, this patch adds a new type struct vector_header that documents the constraints on layout of vectors and pseudovectors, and helps optimizing compilers not get fooled by Emacs's type punning. It also adds the macros XSETTYPED_PVECTYPE XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons. * lisp.h (XVECTOR_SIZE): New convenience macro. All previous uses of XVECTOR (foo)->size replaced to use this macro, to avoid the hassle of writing XVECTOR (foo)->header.size. (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR. (XSETTYPED_PVECTYPE): New macro, specifying the name of the size member. (XSETPVECTYPE): Rewrite in terms of new macro. (XSETPVECTYPESIZE): New macro, specifying both type and size. This is a bit clearer, and further avoids the possibility of undesirable aliasing. (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size. (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XVECTOR_HEADER_SIZE. (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE, since Lisp_Subr is a special case (no "next" field). (ASIZE): Rewrite in terms of XVECTOR_SIZE. (struct vector_header): New type. (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the object, to help avoid aliasing. (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP. (SUBRP): Likewise, since Lisp_Subr is a special case. * lisp.h (struct Lisp_Vector, struct Lisp_Char_Table): (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector): (struct Lisp_Hash_Table): Combine first two members into a single struct vector_header member. All uses of "size" and "next" members changed to be "header.size" and "header.next". * buffer.h (struct buffer): Likewise. * font.h (struct font_spec, struct font_entity, struct font): Likewise. * frame.h (struct frame): Likewise. * process.h (struct Lisp_Process): Likewise. * termhooks.h (struct terminal): Likewise. * window.c (struct save_window_data, struct saved_window): Likewise. * window.h (struct window): Likewise. * alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector): Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems. * buffer.c (init_buffer_once): Likewise. * lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a special case. * process.c (Fformat_network_address): Use local var for size, for brevity. --- src/coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 38e41e7a99e..efe4a7c34a1 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7125,7 +7125,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, components = COMPOSITION_COMPONENTS (prop); if (VECTORP (components)) { - len = XVECTOR (components)->size; + len = XVECTOR_SIZE (components); for (i = 0; i < len; i++) *buf++ = XINT (AREF (components, i)); } -- cgit v1.2.1 From 77b37c05572d1028d0ec2c264ac0ed3a89c0f4da Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 25 Apr 2011 14:34:39 -0700 Subject: * lisp.h: (XVECTOR_SIZE): Remove. All uses replaced with ASIZE. (ASIZE): Now contains previous implementation of XVECTOR_SIZE instead of invoking XVECTOR_SIZE. --- src/coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index efe4a7c34a1..6cd039a0903 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7125,7 +7125,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, components = COMPOSITION_COMPONENTS (prop); if (VECTORP (components)) { - len = XVECTOR_SIZE (components); + len = ASIZE (components); for (i = 0; i < len; i++) *buf++ = XINT (AREF (components, i)); } -- cgit v1.2.1 From 94dcfacf129aa99be3e375187d75a193ffe26bad Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 27 Apr 2011 21:15:29 +0300 Subject: Improve `doprnt' and its usage. (Bug#8545) src/doprnt.c (doprnt): Make sure `format' is never accessed beyond `format_end'. Remove support for %l as a conversion specifier. Don't use xrealloc. Improve diagnostics when the %l size modifier is used. Update the commentary. src/eval.c (verror): Simplify calculation of size_t. src/coding.c (Ffind_operation_coding_system): Fix diagnostic error messages. --- src/coding.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index c14a41036ac..c129c94203c 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9282,14 +9282,15 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) error ("Invalid first argument"); if (nargs < 1 + XFASTINT (target_idx)) - error ("Too few arguments for operation: %s", + error ("Too few arguments for operation `%s'", SDATA (SYMBOL_NAME (operation))); target = args[XFASTINT (target_idx) + 1]; if (!(STRINGP (target) || (EQ (operation, Qinsert_file_contents) && CONSP (target) && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) - error ("Invalid %"pI"dth argument", XFASTINT (target_idx) + 1); + error ("Invalid argument %"pI"d of operation `%s'", + XFASTINT (target_idx) + 1, SDATA (SYMBOL_NAME (operation))); if (CONSP (target)) target = XCAR (target); -- cgit v1.2.1 From 15cbd324fd48e47abd57b8d92c3406c866169d21 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 29 Apr 2011 22:47:29 +0300 Subject: Lift the MOST_POSITIVE_FIXNUM/4 limitation on visited files (bug#8528). src/fileio.c (Finsert_file_contents): Don't limit file size to 1/4 of MOST_POSITIVE_FIXNUM. src/coding.c (coding_alloc_by_realloc): Error out if destination will grow beyond MOST_POSITIVE_FIXNUM. (decode_coding_emacs_mule): Abort if there isn't enough place in charbuf for the composition carryover bytes. Reserve an extra space for up to 2 characters produced in a loop. (decode_coding_iso_2022): Abort if there isn't enough place in charbuf for the composition carryover bytes. --- src/coding.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index c129c94203c..d17346efdcb 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1071,6 +1071,8 @@ coding_set_destination (struct coding_system *coding) static void coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) { + if (coding->dst_bytes >= MOST_POSITIVE_FIXNUM - bytes) + error ("Maximum size of buffer or string exceeded"); coding->destination = (unsigned char *) xrealloc (coding->destination, coding->dst_bytes + bytes); coding->dst_bytes += bytes; @@ -2333,7 +2335,9 @@ decode_coding_emacs_mule (struct coding_system *coding) /* We may produce two annotations (charset and composition) in one loop and one more charset annotation at the end. */ int *charbuf_end - = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); + = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) + /* We can produce up to 2 characters in a loop. */ + - 1; EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; EMACS_INT char_offset = coding->produced_char; @@ -2348,6 +2352,8 @@ decode_coding_emacs_mule (struct coding_system *coding) { int i; + if (charbuf_end - charbuf < cmp_status->length) + abort (); for (i = 0; i < cmp_status->length; i++) *charbuf++ = cmp_status->carryover[i]; coding->annotated = 1; @@ -3479,6 +3485,8 @@ decode_coding_iso_2022 (struct coding_system *coding) if (cmp_status->state != COMPOSING_NO) { + if (charbuf_end - charbuf < cmp_status->length) + abort (); for (i = 0; i < cmp_status->length; i++) *charbuf++ = cmp_status->carryover[i]; coding->annotated = 1; -- cgit v1.2.1 From 2f9442b848594799dd155d455930215df2d2a222 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 1 May 2011 16:37:08 -0700 Subject: * coding.c (detect_coding_charset): Fix typo: * 2 -> *4 (Bug#8601). --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index d17346efdcb..71253df6469 100644 --- a/src/coding.c +++ b/src/coding.c @@ -5368,8 +5368,8 @@ detect_coding_charset (struct coding_system *coding, if (src == src_end) goto too_short; ONE_MORE_BYTE (c); - if (c < charset->code_space[(dim - 1 - idx) * 2] - || c > charset->code_space[(dim - 1 - idx) * 2 + 1]) + if (c < charset->code_space[(dim - 1 - idx) * 4] + || c > charset->code_space[(dim - 1 - idx) * 4 + 1]) break; } if (idx < dim) -- cgit v1.2.1 From 55d4c1b248e84d347ae73278faff623741f52691 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 28 May 2011 15:39:39 -0700 Subject: [ChangeLog] Use 'inline', not 'INLINE'. * configure.in, autogen/config.in (INLINE): Remove. [lib-src/ChangeLog] Use 'inline', not 'INLINE'. * etags.c (hash): Now inline unconditionally. * make-docfile.c (put_char): inline, not INLINE. [nt/ChangeLog] Use 'inline', not 'INLINE'. * config.nt (INLINE): Remove. [src/ChangeLog] Use 'inline', not 'INLINE'. * alloc.c, fontset.c (INLINE): Remove. * alloc.c, bidi.c, charset.c, coding.c, dispnew.c, fns.c, image.c: * intervals.c, keyboard.c, process.c, syntax.c, textprop.c, w32term.c: * xdisp.c, xfaces.c, xterm.c: Replace all uses of INLINE with inline. * gmalloc.c (register_heapinfo): Use inline unconditionally. * lisp.h (LISP_MAKE_RVALUE): Use inline, not __inline__. --- src/coding.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 71253df6469..e257790bbef 100644 --- a/src/coding.c +++ b/src/coding.c @@ -864,21 +864,21 @@ static void decode_eol (struct coding_system *); static Lisp_Object get_translation_table (Lisp_Object, int, int *); static Lisp_Object get_translation (Lisp_Object, int *, int *); static int produce_chars (struct coding_system *, Lisp_Object, int); -static INLINE void produce_charset (struct coding_system *, int *, +static inline void produce_charset (struct coding_system *, int *, EMACS_INT); static void produce_annotation (struct coding_system *, EMACS_INT); static int decode_coding (struct coding_system *); -static INLINE int *handle_composition_annotation (EMACS_INT, EMACS_INT, +static inline int *handle_composition_annotation (EMACS_INT, EMACS_INT, struct coding_system *, int *, EMACS_INT *); -static INLINE int *handle_charset_annotation (EMACS_INT, EMACS_INT, +static inline int *handle_charset_annotation (EMACS_INT, EMACS_INT, struct coding_system *, int *, EMACS_INT *); static void consume_chars (struct coding_system *, Lisp_Object, int); static int encode_coding (struct coding_system *); static Lisp_Object make_conversion_work_buffer (int); static Lisp_Object code_conversion_restore (Lisp_Object); -static INLINE int char_encodable_p (int, Lisp_Object); +static inline int char_encodable_p (int, Lisp_Object); static Lisp_Object make_subsidiaries (Lisp_Object); static void @@ -6829,7 +6829,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ] */ -static INLINE void +static inline void produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) { int len; @@ -6873,7 +6873,7 @@ produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] */ -static INLINE void +static inline void produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) { EMACS_INT from = pos - charbuf[2]; @@ -7101,7 +7101,7 @@ decode_coding (struct coding_system *coding) position of a composition after POS (if any) or to LIMIT, and return BUF. */ -static INLINE int * +static inline int * handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, struct coding_system *coding, int *buf, EMACS_INT *stop) @@ -7184,7 +7184,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, If the property value is nil, set *STOP to the position where the property value is non-nil (limiting by LIMIT), and return BUF. */ -static INLINE int * +static inline int * handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, struct coding_system *coding, int *buf, EMACS_INT *stop) @@ -8435,7 +8435,7 @@ highest priority. */) } -static INLINE int +static inline int char_encodable_p (int c, Lisp_Object attrs) { Lisp_Object tail; -- cgit v1.2.1 From 34809aa6007e2c8ff75f9ec43500e6d34cc43aa3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 30 May 2011 00:09:52 +0300 Subject: src/coding.c: Fix a typo in a comment. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 71253df6469..945f542a2d6 100644 --- a/src/coding.c +++ b/src/coding.c @@ -55,8 +55,8 @@ CODING SYSTEM character sequence of emacs-utf-8 to a byte sequence of a specific coding system. - In Emacs Lisp, a coding system is represented by a Lisp symbol. In - C level, a coding system is represented by a vector of attributes + In Emacs Lisp, a coding system is represented by a Lisp symbol. On + the C level, a coding system is represented by a vector of attributes stored in the hash table Vcharset_hash_table. The conversion from coding system symbol to attributes vector is done by looking up Vcharset_hash_table by the symbol. -- cgit v1.2.1 From d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 5 Jun 2011 23:16:12 -0700 Subject: Check for buffer and string overflow more precisely. * buffer.h (BUF_BYTES_MAX): New macro. * lisp.h (STRING_BYTES_MAX): New macro. * alloc.c (Fmake_string): * character.c (string_escape_byte8): * coding.c (coding_alloc_by_realloc): * doprnt.c (doprnt): * editfns.c (Fformat): * eval.c (verror): Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM, since they may not be the same number. * editfns.c (Finsert_char): * fileio.c (Finsert_file_contents): Likewise for BUF_BYTES_MAX. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 6ccaf354c74..64e8e41a5a1 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1071,8 +1071,8 @@ coding_set_destination (struct coding_system *coding) static void coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) { - if (coding->dst_bytes >= MOST_POSITIVE_FIXNUM - bytes) - error ("Maximum size of buffer or string exceeded"); + if (STRING_BYTES_MAX - coding->dst_bytes < bytes) + string_overflow (); coding->destination = (unsigned char *) xrealloc (coding->destination, coding->dst_bytes + bytes); coding->dst_bytes += bytes; -- cgit v1.2.1 From c9d624c605059127505b6d4baec8f07d6ff731d9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 8 Jun 2011 10:22:24 -0700 Subject: * alloc.c: Catch some string size overflows that we were missing. (XMALLOC_OVERRUN_CHECK_SIZE) [!XMALLOC_OVERRUN_CHECK]: Define to 0, for convenience in STRING_BYTES_MAX. (STRING_BYTES_MAX): New macro, superseding the old one in lisp.h. The definition here is exact; the one in lisp.h was approximate. (allocate_string_data): Check for string overflow. This catches some instances we weren't catching before. Also, it catches size_t overflow on (unusual) hosts where SIZE_MAX <= min (PTRDIFF_MAX, MOST_POSITIVE_FIXNUM), e.g., when size_t is 32 bits and ptrdiff_t and EMACS_INT are both 64 bits. * character.c, coding.c, doprnt.c, editfns.c, eval.c: All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND. * lisp.h (STRING_BYTES_BOUND): Renamed from STRING_BYTES_MAX. --- src/coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 64e8e41a5a1..d914e0d641b 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1071,7 +1071,7 @@ coding_set_destination (struct coding_system *coding) static void coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) { - if (STRING_BYTES_MAX - coding->dst_bytes < bytes) + if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) string_overflow (); coding->destination = (unsigned char *) xrealloc (coding->destination, coding->dst_bytes + bytes); -- cgit v1.2.1 From f66c7cf8f794d6f7fd9ccb8794ffc519e4e89795 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 14 Jun 2011 11:57:19 -0700 Subject: Variadic C functions now count arguments with ptrdiff_t. This partly undoes my 2011-03-30 change, which replaced int with size_t. Back then I didn't know that the Emacs coding style prefers signed int. Also, in the meantime I found a few more instances where arguments were being counted with int, which may truncate counts on 64-bit machines, or EMACS_INT, which may be unnecessarily wide. * lisp.h (struct Lisp_Subr.function.aMANY) (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call): Arg counts are now ptrdiff_t, not size_t. All variadic functions and their callers changed accordingly. (struct gcpro.nvars): Now size_t, not size_t. All uses changed. * bytecode.c (exec_byte_code): Check maxdepth for overflow, to avoid potential buffer overrun. Don't assume arg counts fit in 'int'. * callint.c (Fcall_interactively): Check arg count for overflow, to avoid potential buffer overrun. Use signed char, not 'int', for 'varies' array, so that we needn't bother to check its size calculation for overflow. * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args. * eval.c (apply_lambda): * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length. (struct textprop_rec.argnum): Now ptrdiff_t, not int. All uses changed. (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args. --- src/coding.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index d914e0d641b..04985ab3c74 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9278,7 +9278,7 @@ function to call for FILENAME, that function should examine the contents of BUFFER instead of reading the file. usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object operation, target_idx, target, val; register Lisp_Object chain; @@ -9355,9 +9355,9 @@ If multiple coding systems belong to the same category, all but the first one are ignored. usage: (set-coding-system-priority &rest coding-systems) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { - size_t i, j; + ptrdiff_t i, j; int changed[coding_category_max]; enum coding_category priorities[coding_category_max]; @@ -9461,7 +9461,7 @@ DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, Sdefine_coding_system_internal, coding_arg_max, MANY, 0, doc: /* For internal use only. usage: (define-coding-system-internal ...) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object name; Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ -- cgit v1.2.1