From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31146 invoked by alias); 3 Mar 2010 18:04:55 -0000 Received: (qmail 30882 invoked by uid 22791); 3 Mar 2010 18:04:53 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Mar 2010 18:04:49 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o23I4lVM000503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Mar 2010 13:04:47 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o23I4kDH018074; Wed, 3 Mar 2010 13:04:47 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o23I4kgo003868; Wed, 3 Mar 2010 13:04:46 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 9600D379963; Wed, 3 Mar 2010 11:04:45 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: fix PR 11345 Reply-To: tromey@redhat.com Date: Wed, 03 Mar 2010 18:04:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00112.txt.bz2 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 PR gdb/11345: * printcmd.c (printf_command): Print end of format string using printf_filtered. 2010-03-03 Tom Tromey 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