From a608187fcbe47b23b3a69b928505802f08950e23 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Sun, 10 May 2009 10:28:34 +0000 Subject: * pretty-print.h (struct pretty_print_info): Add translate_identifiers. (pp_translate_identifiers): New. (pp_identifier): Only conditionally translate identifier to locale character set. * pretty-print.c (pp_construct): Set pp_translate_identifiers. (pp_base_tree_identifier): Only conditionally translate identifier to locale character set. * c-pretty-print.c (M_): Define. (pp_c_type_specifier, pp_c_primary_expression): Mark English fragments for conditional translation with M_. * tree-pretty-print.c (maybe_init_pretty_print): Disable identifier translation. cp: * call.c (name_as_c_string): Call type_as_string_translate. Translate identifiers to locale character set. * cp-tree.h (lang_decl_name): Update prototype. (type_as_string_translate, decl_as_string_translate, cxx_printable_name_translate): Declare. * cxx-pretty-print.c (M_): Define. (pp_cxx_unqualified_id, pp_cxx_canonical_template_parameter): Mark English fragments for conditional translation with M_. * decl.c (grokdeclarator): Translate identifiers to locale character set for diagnostics. * error.c (M_): Define. (dump_template_bindings, dump_type, dump_aggr_type, dump_type_prefix, dump_global_iord, dump_simple_decl, dump_decl, dump_function_decl, dump_template_parms, dump_expr, dump_binary_op, op_to_string, assop_to_string): Mark English fragments for conditional translation with M_. (type_as_string): Disable translation of identifiers. (type_as_string_translate): New. (expr_as_string): Disable translation of identifiers. (decl_as_string): Disable translation of identifiers. (decl_as_string_translate): New. (lang_decl_name): Add parameter translate. (args_to_string): Call type_as_string_translate. (cp_print_error_function): Call cxx_printable_name_translate. (print_instantiation_full_context, print_instantiation_partial_context): Call decl_as_string_translate. * parser.c (cp_lexer_get_preprocessor_token): Use %qE for identifier in diagnostic. * tree.c (cxx_printable_name): Change to cxx_printable_name_internal. Add parameter translate. (cxx_printable_name, cxx_printable_name_translate): New wrappers round cxx_printable_name_internal. objc: * objc-act.c: Include intl.h. (objc_lookup_protocol): Use complete sentences for diagnostics with %qE for identifiers and translating results of gen_type_name_0 to locale character set. (objc_check_decl, check_protocol_recursively, lookup_and_install_protocols, objc_build_string_object, objc_get_class_reference, objc_declare_alias, objc_declare_class, objc_get_class_ivars, error_with_ivar, check_duplicates, objc_finish_message_expr, objc_build_protocol_expr, objc_build_selector_expr, build_ivar_reference, objc_add_method, add_category, add_instance_variable, objc_is_public, check_methods, check_methods_accessible, check_protocol, start_class, finish_class, start_protocol, really_start_method, get_super_receiver, objc_lookup_ivar): Use %E and %qE for identifiers in diagnostics. Translate generated text to locale character set as needed. (check_protocol, check_protocols): Change name parameter to type tree. (lang_report_error_function): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147333 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/pretty-print.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gcc/pretty-print.c') diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index d531075c933..55bc3feeeac 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -719,6 +719,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length) pp_line_cutoff (pp) = maximum_length; pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE; pp_set_prefix (pp, prefix); + pp_translate_identifiers (pp) = true; } /* Append a string delimited by START and END to the output area of @@ -855,8 +856,14 @@ pp_base_maybe_space (pretty_printer *pp) void pp_base_tree_identifier (pretty_printer *pp, tree id) { - const char *text = identifier_to_locale (IDENTIFIER_POINTER (id)); - pp_append_text (pp, text, text + strlen (text)); + if (pp_translate_identifiers (pp)) + { + const char *text = identifier_to_locale (IDENTIFIER_POINTER (id)); + pp_append_text (pp, text, text + strlen (text)); + } + else + pp_append_text (pp, IDENTIFIER_POINTER (id), + IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id)); } /* The string starting at P has LEN (at least 1) bytes left; if they -- cgit v1.2.1