mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
Rewrite Fortran character printer
This adds a Fortran-specific subclass of wchar_printer and arranges to use it.
This commit is contained in:
parent
444c9b4946
commit
9048449790
2 changed files with 4 additions and 41 deletions
27
gdb/f-lang.c
27
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 *
|
||||
|
|
|
|||
18
gdb/f-lang.h
18
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).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue