From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19604 invoked by alias); 23 Apr 2008 09:29:24 -0000 Received: (qmail 19591 invoked by uid 22791); 23 Apr 2008 09:29:23 -0000 X-Spam-Check-By: sourceware.org Received: from s200aog13.obsmtp.com (HELO s200aog13.obsmtp.com) (207.126.144.127) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 23 Apr 2008 09:29:01 +0000 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob013.postini.com ([207.126.147.11]) with SMTP; Wed, 23 Apr 2008 09:28:57 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 4BAE2DA8B for ; Wed, 23 Apr 2008 09:28:46 +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 AC0C24BF68 for ; Wed, 23 Apr 2008 09:28:40 +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 CKB59368 (AUTH stubbsa); Wed, 23 Apr 2008 10:27:45 +0100 (BST) Message-ID: <480F0146.7090103@st.com> Date: Wed, 23 Apr 2008 10:26: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> In-Reply-To: <20080422180204.GA20664@caradoc.them.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/msg00506.txt.bz2 Daniel Jacobowitz wrote: > However, for host types we could import the printf (vsprintf-posix) > module from gnulib, then always assume PRINTF_HAS_LONG_LONG as long as > HAVE_LONG_LONG_INT. I did the work of adding gnulib modules already. > So maybe this is a better option. What do you think? I'm not sufficiently familiar with gnulib to know what gotchas there might be, but I imagine it would at least solve the problem of different behaviour on different hosts, given the same target. That said, selfishly speaking, it's overkill for _my_ problem, and I don't know of any other problems in this area - apart from hosts that just plain don't have long long, and you seem to suggest that gnulib won't solve that? >> + /* 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; > > You've got enough buffer space to do this but I had to think about it > a couple times to work out why :-) Unless I'm mistaken, the code reserves enough space for every character to be in it's own nul-terminated substring, but since the minimum length %-spec is two characters, that's impossible. In this specific example, there would be 8 bytes reserved for the string "%lld" - enough for "%\0l\0l\0d\0", but "%I64d\0" only uses 6.