aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2010-05-17 16:53:21 +0000
committerAndreas Schwab <schwab@linux-m68k.org>2010-05-17 16:53:21 +0000
commit3872d37d18fb4e3c92df4c5816876e651e1fd3bf (patch)
tree341d417fd6eb0a181a15c1b6bb02e3743a38ef75 /gdb/c-lang.c
parentd09039ddeb9c1722772f36321e10bcc6751e9e42 (diff)
downloadgdb-3872d37d18fb4e3c92df4c5816876e651e1fd3bf.zip
gdb-3872d37d18fb4e3c92df4c5816876e651e1fd3bf.tar.gz
gdb-3872d37d18fb4e3c92df4c5816876e651e1fd3bf.tar.bz2
PR gdb/11092
* c-lang.c (c_printstr): Compute real length of NUL terminated string at first.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 63be331..40c4172 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -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);