git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Herland <johan@herland.net>
To: Nanako Shiraishi <nanako3@lavabit.com>,
	"Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: [PATCH] Use strchrnul() instead of strchr() plus manual workaround
Date: Sun, 28 Sep 2008 00:24:36 +0200	[thread overview]
Message-ID: <200809280024.36190.johan@herland.net> (raw)
In-Reply-To: <20080928070858.6117@nanako3.lavabit.com>

Also gets rid of a C++ comment.

Signed-off-by: Johan Herland <johan@herland.net>
---

On Sunday 28 September 2008, Nanako Shiraishi wrote:
> Why does this C++ style comment talk about "simulate"?
>
> Don't other parts of git already use strchrnul()?

Oops. Sorry about that. The man page for strchrnul() says that it is
a GNU extension, so I stayed away from it. Of course, I should have
grepped the git source instead...

This should fix it.


...Johan

 builtin-for-each-ref.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index e59bd80..fa6c1ed 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -320,9 +320,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
 
 static const char *copy_line(const char *buf)
 {
-	const char *eol = strchr(buf, '\n');
-	if (!eol) // simulate strchrnul()
-		eol = buf + strlen(buf);
+	const char *eol = strchrnul(buf, '\n');
 	return xmemdupz(buf, eol - buf);
 }
 
-- 
1.6.0.2.471.g47a76

      reply	other threads:[~2008-09-27 22:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-27 22:08 [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines Nanako Shiraishi
2008-09-27 22:24 ` Johan Herland [this message]

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=200809280024.36190.johan@herland.net \
    --to=johan@herland.net \
    --cc=git@vger.kernel.org \
    --cc=nanako3@lavabit.com \
    --cc=spearce@spearce.org \
    /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).