From: Jeff King <peff@peff.net>
To: Erik Faye-Lund <kusmabite@gmail.com>
Cc: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
Kirill Likhodedov <Kirill.Likhodedov@jetbrains.com>,
Johannes Sixt <j.sixt@viscovery.net>,
git@vger.kernel.org
Subject: Re: git log doesn't allow %x00 in custom format anymore?
Date: Thu, 7 Oct 2010 14:33:42 -0400 [thread overview]
Message-ID: <20101007183342.GA20289@sigill.intra.peff.net> (raw)
In-Reply-To: <AANLkTikkZaCQKFTnQ=k2Ajp_6mVRd6mrP1P7bEASEGgd@mail.gmail.com>
On Thu, Oct 07, 2010 at 08:19:01PM +0200, Erik Faye-Lund wrote:
> Yeah. When I read K&R a bit closer, I find this:
>
> "A number specifying a minimum field width. The converted argument
> will be printed in a field _at least this wide_, and wider if
> necessary. If the converted argument has fewer characters than the
> field width _it will be padded_ on the left (or right, if left
> adjustment has been requested) to make up the field width."
You are confusing field width (%*s) with precision (%.*s) here.
C89 is pretty clear that the behavior I am seeing is mandated:
7.19.6.1, paragraph 4:
An optional precision that gives ... the maximum number of bytes to
be written for s conversions.
7.19.6.1, paragraph 8, item "s":
... Characters from the array are written up to (but not including)
the terminating null character. If the precision is specified, no
more than that many bytes are written. If the precision is not
specified or is greater than the size of the array, the array shall
contain a null character.
so it is always about giving a maximum to print an unterminated string,
or to print a partial string. But printf always stops at a NUL.
-Peff
next prev parent reply other threads:[~2010-10-07 18:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 11:25 git log doesn't allow %x00 in custom format anymore? Kirill Likhodedov
2010-10-07 14:10 ` Jeff King
2010-10-07 14:35 ` Kirill Likhodedov
2010-10-07 14:46 ` Jeff King
2010-10-07 15:07 ` Johannes Sixt
2010-10-07 15:18 ` Kirill Likhodedov
2010-10-07 17:29 ` Jeff King
2010-10-07 17:40 ` Matthieu Moy
2010-10-07 18:02 ` Drew Northup
2010-10-07 17:41 ` Erik Faye-Lund
2010-10-07 17:43 ` Erik Faye-Lund
2010-10-07 17:50 ` Jeff King
2010-10-07 17:52 ` Matthieu Moy
2010-10-07 17:53 ` Jeff King
2010-10-07 18:05 ` Erik Faye-Lund
2010-10-07 18:13 ` Jeff King
2010-10-07 18:19 ` Erik Faye-Lund
2010-10-07 18:33 ` Jeff King [this message]
2010-10-07 18:37 ` Erik Faye-Lund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101007183342.GA20289@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Kirill.Likhodedov@jetbrains.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=kusmabite@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).