break;
}
- gdb_putc ('\'', stream);
- generic_emit_char (c, type, stream, '\'', encoding);
- gdb_putc ('\'', stream);
+ generic_emit_char (c, type, stream, encoding);
}
/* Print the character string STRING, printing at most LENGTH
void printchar (int ch, struct type *chtype,
struct ui_file *stream) const override
{
- gdb_puts ("'", stream);
const char *encoding = get_encoding (chtype);
- generic_emit_char (ch, chtype, stream, '\'', encoding);
- gdb_puts ("'", stream);
+ generic_emit_char (ch, chtype, stream, encoding);
}
/* See language.h. */
rust_language::printchar (int ch, struct type *chtype,
struct ui_file *stream) const
{
- fputs_filtered ("'", stream);
if (!rust_chartype_p (chtype))
- generic_emit_char (ch, chtype, stream, '\'',
- target_charset (chtype->arch ()));
- else if (ch == '\\')
+ {
+ generic_emit_char (ch, chtype, stream,
+ target_charset (chtype->arch ()));
+ return;
+ }
+ gdb_puts ("'", stream);
+ if (ch == '\\')
gdb_printf (stream, "\\%c", ch);
else if (ch == '\n')
gdb_puts ("\\n", stream);
}
/* Print the character C on STREAM as part of the contents of a
- literal string whose delimiter is QUOTER. ENCODING names the
- encoding of C. */
+ literal string whose delimiter is a single quote. ENCODING names
+ the encoding of C. */
void
generic_emit_char (int c, struct type *type, struct ui_file *stream,
- int quoter, const char *encoding)
+ const char *encoding)
{
+ /* The quote character. */
+ constexpr int quoter = '\'';
+
enum bfd_endian byte_order
= type_byte_order (type);
gdb_byte *c_buf;
c_buf = (gdb_byte *) alloca (type->length ());
pack_long (c_buf, type, c);
+ gdb_putc (quoter, stream);
wchar_iterator iter (c_buf, type->length (), encoding, type->length ());
/* This holds the printable form of the wchar_t data. */
obstack_1grow (&output, '\0');
gdb_puts ((const char *) obstack_base (&output), stream);
+ gdb_putc (quoter, stream);
}
/* Return the repeat count of the next character/byte in ITER,
const struct generic_val_print_decorations *d);
extern void generic_emit_char (int c, struct type *type, struct ui_file *stream,
- int quoter, const char *encoding);
+ const char *encoding);
extern void generic_printstr (struct ui_file *stream, struct type *type,
const gdb_byte *string, unsigned int length,