This adds a Fortran-specific subclass of wchar_printer and arranges to
use it.
---
gdb/f-lang.c | 27 ---------------------------
gdb/f-lang.h | 19 +++++--------------
2 files changed, 5 insertions(+), 41 deletions(-)
@@ -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 *
@@ -25,6 +25,7 @@
#include "language.h"
#include "valprint.h"
+#include "char-print.h"
struct type_print_options;
struct parser_state;
@@ -161,8 +162,8 @@ class f_language : public language_defn
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 printer (chtype, '\'');
+ printer.print (ch, stream);
}
/* See language.h. */
@@ -172,16 +173,11 @@ class f_language : public language_defn
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 +233,6 @@ class f_language : public language_defn
(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).