Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* FYI: fix PR 11345
@ 2010-03-03 18:04 Tom Tromey
  2010-03-03 18:22 ` Tom Tromey
  2010-03-04  0:47 ` Pedro Alves
  0 siblings, 2 replies; 12+ messages in thread
From: Tom Tromey @ 2010-03-03 18:04 UTC (permalink / raw)
  To: gdb-patches

I'm checking this in.

This fixes PR 11345.  The bug is that "%%" doesn't work if it appears
after the last format in a printf:

(gdb) printf "%%\n"
%%

The fix is to use printf, not puts, to print the rest of the format
string.  This is always ok because we know that there are no format
specifiers other than "%%" in the string.

The patch comes from the PR; it is small enough not to need papers.  I
wrote the test case and updated the comment in printf_command.

Built and regression tested on x86-64 (compile farm).

Tom

2010-03-03  Dainis Jonitis  <jonitis@gmail.com>

	PR gdb/11345:
	* printcmd.c (printf_command): Print end of format string using
	printf_filtered.

2010-03-03  Tom Tromey  <tromey@redhat.com>

	PR gdb/11345:
	* gdb.base/printcmds.exp (test_printf): Add test.

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c8cb35c..5e5ef8e 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2642,8 +2642,11 @@ printf_command (char *arg, int from_tty)
 	/* Skip to the next substring.  */
 	current_substring += strlen (current_substring) + 1;
       }
-    /* Print the portion of the format string after the last argument.  */
-    puts_filtered (last_arg);
+    /* Print the portion of the format string after the last argument.
+       Note that this will not include any ordinary %-specs, but it
+       might include "%%".  That is why we use printf_filtered and not
+       puts_filtered here.  */
+    printf_filtered (last_arg);
   }
   do_cleanups (old_cleanups);
 }
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 5598bde..9c2cd6b 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -686,6 +686,10 @@ proc test_printf {} {
 
     # Regression test for C lexer bug.
     gdb_test "printf \"%c\\n\", \"x\"\[1,0\]" "x"
+
+    # Regression test for "%% at end of format string.
+    # See http://sourceware.org/bugzilla/show_bug.cgi?id=11345
+    gdb_test "printf \"%%%d%%\\n\", 5" "%5%"
 }
 
 #Test printing DFP values with printf


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-03-04 18:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-03 18:04 FYI: fix PR 11345 Tom Tromey
2010-03-03 18:22 ` Tom Tromey
2010-03-04  0:47 ` Pedro Alves
2010-03-04  2:35   ` Doug Evans
2010-03-04  2:43     ` Pedro Alves
2010-03-04  2:56       ` Doug Evans
2010-03-04  3:01         ` Pedro Alves
2010-03-04  2:36   ` Tom Tromey
2010-03-04 17:01   ` Tom Tromey
2010-03-04 17:20     ` Pedro Alves
2010-03-04 17:28       ` Doug Evans
2010-03-04 18:21         ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox