diff --git a/gdb/f-lang.c b/gdb/f-lang.c index c3cf7c62abe..2cebe14ecb3 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -73,33 +73,6 @@ static value *fortran_prepare_argument (struct expression *exp, int arg_num, bool is_internal_call_p, struct type *func_type, enum noside noside); -/* Return the encoding that should be used for the character type - TYPE. */ - -const char * -f_language::get_encoding (struct type *type) -{ - const char *encoding; - - switch (type->length ()) - { - case 1: - encoding = target_charset (type->arch ()); - break; - case 4: - if (type_byte_order (type) == BFD_ENDIAN_BIG) - encoding = "UTF-32BE"; - else - encoding = "UTF-32LE"; - break; - - default: - error (_("unrecognized character type")); - } - - return encoding; -} - /* See language.h. */ struct value * diff --git a/gdb/f-lang.h b/gdb/f-lang.h index e8dc784f077..7f43957c887 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -25,6 +25,7 @@ #include "language.h" #include "valprint.h" +#include "char-print.h" struct type_print_options; struct parser_state; @@ -161,8 +162,7 @@ public: void printchar (int ch, struct type *chtype, struct ui_file *stream) const override { - const char *encoding = get_encoding (chtype); - generic_emit_char (ch, chtype, stream, encoding); + wchar_printer (chtype, '\'').print (ch, stream); } /* See language.h. */ @@ -172,16 +172,11 @@ public: const char *encoding, int force_ellipses, const struct value_print_options *options) const override { - const char *type_encoding = get_encoding (elttype); - if (elttype->length () == 4) gdb_puts ("4_", stream); - if (!encoding || !*encoding) - encoding = type_encoding; - - generic_printstr (stream, elttype, string, length, encoding, - force_ellipses, '\'', 0, options); + wchar_printer printer (elttype, '\'', encoding); + printer.print (stream, string, length, force_ellipses, 0, options); } /* See language.h. */ @@ -237,11 +232,6 @@ protected: (const lookup_name_info &lookup_name) const override; private: - /* Return the encoding that should be used for the character type - TYPE. */ - - static const char *get_encoding (struct type *type); - /* Print any asterisks or open-parentheses needed before the variable name (to describe its type).