aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-09-22 16:06:03 -0600
committerTom Tromey <tom@tromey.com>2019-10-01 15:12:37 -0600
commit0dfe5bfbb7e7a3e55c57d1b59c265dc1a3cd9fc7 (patch)
tree7d49e611a4042f0e496d6c231879d40bd2ff2164 /gdb/unittests
parente43b10e10eba9d9493a0ad40176b2aea9cfb62ab (diff)
downloadgdb-0dfe5bfbb7e7a3e55c57d1b59c265dc1a3cd9fc7.zip
gdb-0dfe5bfbb7e7a3e55c57d1b59c265dc1a3cd9fc7.tar.gz
gdb-0dfe5bfbb7e7a3e55c57d1b59c265dc1a3cd9fc7.tar.bz2
Don't create empty literal pieces
I noticed that format_pieces can create an empty literal piece. However, there's never a need for one, so this patch removes the possibility. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * unittests/format_pieces-selftests.c: Update. Add final format. * gdbsupport/format.c (format_pieces::format_pieces): Don't add empty literal pieces.
Diffstat (limited to 'gdb/unittests')
-rw-r--r--gdb/unittests/format_pieces-selftests.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/unittests/format_pieces-selftests.c b/gdb/unittests/format_pieces-selftests.c
index 7d31b3c..862b2da 100644
--- a/gdb/unittests/format_pieces-selftests.c
+++ b/gdb/unittests/format_pieces-selftests.c
@@ -48,13 +48,15 @@ test_escape_sequences ()
static void
test_format_specifier ()
{
- check ("Hello %d%llx%%d", /* ARI: %ll */
+ /* The format string here ends with a % sequence, to ensure we don't
+ see a trailing empty literal piece. */
+ check ("Hello %d%llx%%d%d", /* ARI: %ll */
{
format_piece ("Hello ", literal_piece),
format_piece ("%d", int_arg),
- format_piece ("", literal_piece),
format_piece ("%llx", long_long_arg), /* ARI: %ll */
format_piece ("%%d", literal_piece),
+ format_piece ("%d", int_arg),
});
}