* Re: [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines
@ 2008-09-27 22:08 Nanako Shiraishi
2008-09-27 22:24 ` [PATCH] Use strchrnul() instead of strchr() plus manual workaround Johan Herland
0 siblings, 1 reply; 2+ messages in thread
From: Nanako Shiraishi @ 2008-09-27 22:08 UTC (permalink / raw)
To: Johan Herland; +Cc: git, Shawn O. Pearce
Johan Herland <johan@herland.net> writes:
> builtin-for-each-ref.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
> index 9b44092..e59bd80 100644
> --- a/builtin-for-each-ref.c
> +++ b/builtin-for-each-ref.c
> @@ -321,8 +321,8 @@ 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)
> - return "";
> + if (!eol) // simulate strchrnul()
> + eol = buf + strlen(buf);
> return xmemdupz(buf, eol - buf);
> }
Why does this C++ style comment talk about "simulate"?
Don't other parts of git already use strchrnul()?
--
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] Use strchrnul() instead of strchr() plus manual workaround
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
0 siblings, 0 replies; 2+ messages in thread
From: Johan Herland @ 2008-09-27 22:24 UTC (permalink / raw)
To: Nanako Shiraishi, Shawn O. Pearce; +Cc: git
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-09-27 22:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-27 22:08 [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines Nanako Shiraishi
2008-09-27 22:24 ` [PATCH] Use strchrnul() instead of strchr() plus manual workaround Johan Herland
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).