summaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2009-07-07 21:33:48 +0000
committerTom Tromey <tromey@redhat.com>2009-07-07 21:33:48 +0000
commit98e3eafe23fd42d4744de2e6192d025f8a509ec6 (patch)
treecb2ea1b5a37b6f2618a68391b2cd25cc695c517a /gdb/c-lang.c
parent301f55165a0298671b8bdded97fd3900af02739b (diff)
downloadgdb-98e3eafe23fd42d4744de2e6192d025f8a509ec6.tar.gz
gdb
* c-lang.c (convert_octal): Only allow 3 octal digits. (print_wchar): Prefer 3-digit octal form. Fall back to hex if needed. * c-exp.y (c_parse_escape): Only allow 3 octal digits. gdb/testsuite * gdb.base/call-rt-st.exp: Update for change to escape output. * gdb.base/callfuncs.exp: Likewise. * gdb.base/charset.exp: Likewise. * gdb.base/constvars.exp: Likewise. * gdb.base/long_long.exp: Likewise. * gdb.base/pointers.exp: Likewise. * gdb.base/printcmds.exp: Likewise. * gdb.base/setvar.exp: Likewise. * gdb.base/store.exp: Likewise. * gdb.cp/ref-types.exp: Likewise. * gdb.mi/mi-var-child.exp: Likewise. * gdb.mi/mi-var-display.exp: Likewise. * gdb.mi/mi2-var-display.exp: Likewise. * gdb.base/charset.exp: Test octal escape sequence length. Update for change to escape output.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 55dc042dfee..5cbecd26b5c 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -225,7 +225,12 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
char octal[30];
ULONGEST value;
value = extract_unsigned_integer (&orig[i], width, byte_order);
- sprintf (octal, "\\%lo", (long) value);
+ /* If the value fits in 3 octal digits, print it that
+ way. Otherwise, print it as a hex escape. */
+ if (value <= 0777)
+ sprintf (octal, "\\%.3o", (int) (value & 0777));
+ else
+ sprintf (octal, "\\x%lx", (long) value);
append_string_as_wide (octal, output);
}
/* If we somehow have extra bytes, print them now. */
@@ -770,9 +775,12 @@ emit_numeric_character (struct type *type, unsigned long value,
static char *
convert_octal (struct type *type, char *p, char *limit, struct obstack *output)
{
+ int i;
unsigned long value = 0;
- while (p < limit && isdigit (*p) && *p != '8' && *p != '9')
+ for (i = 0;
+ i < 3 && p < limit && isdigit (*p) && *p != '8' && *p != '9';
+ ++i)
{
value = 8 * value + host_hex_value (*p);
++p;