Skip to content

Commit

Permalink
Use strchrnul() instead of strchr() plus manual workaround
Browse files Browse the repository at this point in the history
Also gets rid of a C++ comment.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Johan Herland authored and Shawn O. Pearce committed Sep 29, 2008
1 parent 175a494 commit 94e02e7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions builtin-for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 94e02e7

Please sign in to comment.