aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-06-10 15:42:01 +0000
committerJakub Jelinek <jakub@redhat.com>2010-06-10 15:42:01 +0000
commit3baae9d67ef47142e1d2681aa11a4640414a9748 (patch)
treea316bf0d926b6199dfdc3de338bddad2eecf0fdb /libiberty
parente466bc6e485561699f25fc02085b1b128bb95dfb (diff)
downloadgdb-3baae9d67ef47142e1d2681aa11a4640414a9748.zip
gdb-3baae9d67ef47142e1d2681aa11a4640414a9748.tar.gz
gdb-3baae9d67ef47142e1d2681aa11a4640414a9748.tar.bz2
PR other/43838
* cp-demangle.c (struct d_print_info): Add flush_count field. (d_print_init): Initialize it to 0. (d_print_flush): Increment it. (d_print_comp): If needed flush before appending ", ". Only decrement dpi->len if no flushes happened during the recursive call. * testsuite/demangle-expected: Add a test for this.
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog11
-rw-r--r--libiberty/cp-demangle.c12
-rw-r--r--libiberty/testsuite/demangle-expected3
3 files changed, 25 insertions, 1 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 744f6ae..4c0cba8 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,14 @@
+2010-06-10 Jakub Jelinek <jakub@redhat.com>
+
+ PR other/43838
+ * cp-demangle.c (struct d_print_info): Add flush_count field.
+ (d_print_init): Initialize it to 0.
+ (d_print_flush): Increment it.
+ (d_print_comp): If needed flush before appending ", ". Only
+ decrement dpi->len if no flushes happened during the recursive
+ call.
+ * testsuite/demangle-expected: Add a test for this.
+
2010-06-03 Joern Rennecke <joern.rennecke@embecosm.com>
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 6db1f78..d2d15e9 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -302,6 +302,8 @@ struct d_print_info
/* The current index into any template argument packs we are using
for printing. */
int pack_index;
+ /* Number of d_print_flush calls so far. */
+ unsigned long int flush_count;
};
#ifdef CP_DEMANGLE_DEBUG
@@ -3285,6 +3287,7 @@ d_print_init (struct d_print_info *dpi, int options,
dpi->last_char = '\0';
dpi->templates = NULL;
dpi->modifiers = NULL;
+ dpi->flush_count = 0;
dpi->callback = callback;
dpi->opaque = opaque;
@@ -3314,6 +3317,7 @@ d_print_flush (struct d_print_info *dpi)
dpi->buf[dpi->len] = '\0';
dpi->callback (dpi->buf, dpi->len, dpi->opaque);
dpi->len = 0;
+ dpi->flush_count++;
}
/* Append characters and buffers for printing. */
@@ -4047,12 +4051,18 @@ d_print_comp (struct d_print_info *dpi,
if (d_right (dc) != NULL)
{
size_t len;
+ unsigned long int flush_count;
+ /* Make sure ", " isn't flushed by d_append_string, otherwise
+ dpi->len -= 2 wouldn't work. */
+ if (dpi->len >= sizeof (dpi->buf) - 2)
+ d_print_flush (dpi);
d_append_string (dpi, ", ");
len = dpi->len;
+ flush_count = dpi->flush_count;
d_print_comp (dpi, d_right (dc));
/* If that didn't print anything (which can happen with empty
template argument packs), remove the comma and space. */
- if (dpi->len == len)
+ if (dpi->flush_count == flush_count && dpi->len == len)
dpi->len -= 2;
}
return;
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index ef84bc1..15a0fe7 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -3951,6 +3951,9 @@ decltype (({parm#1}.(operator-))()) h<A>(A)
--format=gnu-v3
_Z1fDn
f(decltype(nullptr))
+--format=gnu-v3
+_ZN5aaaaa6bbbbbb5cccccIN23ddddddddddddddddddddddd3eeeENS2_4ffff16ggggggggggggggggENS0_9hhhhhhhhhES6_S6_S6_S6_S6_S6_S6_EE
+aaaaa::bbbbbb::ccccc<ddddddddddddddddddddddd::eee, ddddddddddddddddddddddd::ffff::gggggggggggggggg, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh>
#
# Ada (GNAT) tests.
#