From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19960 invoked by alias); 23 Apr 2008 13:23:02 -0000 Received: (qmail 19943 invoked by uid 22791); 23 Apr 2008 13:23:01 -0000 X-Spam-Check-By: sourceware.org Received: from s200aog12.obsmtp.com (HELO s200aog12.obsmtp.com) (207.126.144.126) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 23 Apr 2008 13:22:39 +0000 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob012.postini.com ([207.126.147.11]) with SMTP; Wed, 23 Apr 2008 13:22:36 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A9980DAB9 for ; Wed, 23 Apr 2008 13:22:30 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 72D074C14A for ; Wed, 23 Apr 2008 13:22:30 +0000 (GMT) Received: from [164.129.12.194] (bri0669.bri.st.com [164.129.12.194]) by mail1.bri.st.com (MOS 3.7.5a-GA) with ESMTP id CKB62192 (AUTH stubbsa); Wed, 23 Apr 2008 14:21:36 +0100 (BST) Message-ID: <480F3816.8060209@st.com> Date: Wed, 23 Apr 2008 16:12:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Andrew STUBBS , GDB Patches Subject: Re: [PATCH] long long for printf on MinGW References: <452CCE2D.8070806@st.com> <20061011130330.GA24187@nevyn.them.org> <452D09E8.5090005@st.com> <20080422180204.GA20664@caradoc.them.org> <480F0146.7090103@st.com> <20080423115213.GA16165@caradoc.them.org> In-Reply-To: <20080423115213.GA16165@caradoc.them.org> Content-Type: multipart/mixed; boundary="------------020905060205000304050001" X-IsSubscribed: yes 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: 2008-04/txt/msg00520.txt.bz2 This is a multi-part message in MIME format. --------------020905060205000304050001 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 243 Daniel Jacobowitz wrote: > Go ahead with the patch. We can rip it out if we switch to gnulib's > printf. Committed. I've attached the final verion. It's only the patch offsets that have changed since the last patch posted. Thanks Andrew --------------020905060205000304050001 Content-Type: text/plain; name="updated-printf.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="updated-printf.patch" Content-length: 1727 2008-04-23 Andrew Stubbs * printcmd.c: Define USE_PRINTF_I64 and PRINTF_HAS_LONG_LONG on MinGW. (printf_command): Convert %lld to %I64d when USE_PRINTF_I64 set. Index: gdb/printcmd.c =================================================================== RCS file: /cvs/src/src/gdb/printcmd.c,v retrieving revision 1.117 diff -u -p -r1.117 printcmd.c --- gdb/printcmd.c 30 Jan 2008 19:19:51 -0000 1.117 +++ gdb/printcmd.c 23 Apr 2008 12:05:33 -0000 @@ -47,6 +47,13 @@ #include "tui/tui.h" /* For tui_active et.al. */ #endif +#if defined(__MINGW32__) +# define USE_PRINTF_I64 1 +# define PRINTF_HAS_LONG_LONG +#else +# define USE_PRINTF_I64 0 +#endif + extern int asm_demangle; /* Whether to demangle syms in asm printouts */ extern int addressprint; /* Whether to print hex addresses in HLL " */ @@ -2009,8 +2016,23 @@ printf_command (char *arg, int from_tty) *f); f++; - strncpy (current_substring, last_arg, f - last_arg); - current_substring += f - last_arg; + + if (lcount > 1 && USE_PRINTF_I64) + { + /* Windows' printf does support long long, but not the usual way. + Convert %lld to %I64d. */ + int length_before_ll = f - last_arg - 1 - lcount; + strncpy (current_substring, last_arg, length_before_ll); + strcpy (current_substring + length_before_ll, "I64"); + current_substring[length_before_ll + 3] = + last_arg[length_before_ll + lcount]; + current_substring += length_before_ll + 4; + } + else + { + strncpy (current_substring, last_arg, f - last_arg); + current_substring += f - last_arg; + } *current_substring++ = '\0'; last_arg = f; argclass[nargs_wanted++] = this_argclass; --------------020905060205000304050001--