PR gdb/11092

* c-lang.c (c_printstr): Compute real length of NUL terminated
string at first.
This commit is contained in:
Andreas Schwab 2010-05-17 16:53:21 +00:00
parent d09039ddeb
commit 3872d37d18
2 changed files with 19 additions and 13 deletions

View File

@ -1,3 +1,9 @@
2010-05-17 Andreas Schwab <schwab@redhat.com>
PR gdb/11092
* c-lang.c (c_printstr): Compute real length of NUL terminated
string at first.
2010-05-17 Pierre Muller <muller@ics.u-strasbg.fr>
* dwarf2read.c (read_set_type): Set type length if

View File

@ -390,6 +390,19 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
int finished = 0;
int need_escape = 0;
if (length == -1)
{
unsigned long current_char = 1;
for (i = 0; current_char; ++i)
{
QUIT;
current_char = extract_unsigned_integer (string + i * width,
width, byte_order);
}
length = i;
}
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in traditional C
style. */
@ -424,19 +437,6 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
return;
}
if (length == -1)
{
unsigned long current_char = 1;
for (i = 0; current_char; ++i)
{
QUIT;
current_char = extract_unsigned_integer (string + i * width,
width, byte_order);
}
length = i;
}
/* Arrange to iterate over the characters, in wchar_t form. */
iter = make_wchar_iterator (string, length * width, encoding, width);
cleanup = make_cleanup_wchar_iterator (iter);