diff options
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r-- | gdb/c-lang.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c index f052401..9fccc1f 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -484,13 +484,6 @@ convert_hex (struct type *type, const char *p, return p; } -#define ADVANCE \ - do { \ - ++p; \ - if (p == limit) \ - error (_("Malformed escape sequence")); \ - } while (0) - /* Convert an escape sequence to a target format. TYPE is the target character type to use, and DEST_CHARSET is the name of the target character set. The backslash of the escape sequence is at *P, and @@ -502,18 +495,29 @@ static const char * convert_escape (struct type *type, const char *dest_charset, const char *p, const char *limit, struct obstack *output) { + auto advance = [&] () + { + ++p; + if (p == limit) + error (_("Malformed escape sequence")); + }; + /* Skip the backslash. */ - ADVANCE; + advance (); switch (*p) { case '\\': - obstack_1grow (output, '\\'); + /* Convert the backslash itself. This is probably overkill but + it doesn't hurt to do the full conversion. */ + convert_between_encodings (host_charset (), dest_charset, + (const gdb_byte *) p, 1, 1, + output, translit_none); ++p; break; case 'x': - ADVANCE; + advance (); if (!ISXDIGIT (*p)) error (_("\\x used with no following hex digits.")); p = convert_hex (type, p, limit, output); @@ -535,7 +539,7 @@ convert_escape (struct type *type, const char *dest_charset, { int length = *p == 'u' ? 4 : 8; - ADVANCE; + advance (); if (!ISXDIGIT (*p)) error (_("\\u used with no following hex digits")); p = convert_ucn (p, limit, dest_charset, output, length); |