Re: git log doesn't allow %x00 in custom format anymore?
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Oct 7, 2010, 18:05 UTC
- Message-ID
- <AANLkTinu6fhd9DwfJpjiaxOUu_MrTym_RepR9f44=vrv@mail.gmail.com>
- In-Reply-To
- <20101007175358.GD12130@sigill.intra.peff.net>
On Thu, Oct 7, 2010 at 7:53 PM, Jeff King <peff@peff.net> wrote:
Show 17 quoted lines
> On Thu, Oct 07, 2010 at 07:52:42PM +0200, Matthieu Moy wrote:
>
>> Erik Faye-Lund <kusmabite@gmail.com> writes:
>>
>> > Also, fwriting like that to stdout might be a bit troublesome on
>> > Windows because the string won't end up going through our
>> > ANSI-emulation.
>>
>> I don't know which one would be most portable, but if fwrite is the
>> problem, then
>>
>> printf("%*s%c", buf.buf, buf.len, info->hdr_termination);
>>
>> should do the trick.
>
> It does work, but you have to cast the buf.len size_t to an int.
>I'm not sure how portable it is, though. This is what K&R has to say on the matter: "characters from the string are printed until a ´\0´ is reached or until the number of characters indicated by the precision have been printed". To me it's not clear if that means that either cases can terminate the printing when the precision has been specified.