Skip to content

Commit 94e02e7

Browse files
jherlandspearce
authored andcommitted
Use strchrnul() instead of strchr() plus manual workaround
Also gets rid of a C++ comment. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent 175a494 commit 94e02e7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

builtin-for-each-ref.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
320320

321321
static const char *copy_line(const char *buf)
322322
{
323-
const char *eol = strchr(buf, '\n');
324-
if (!eol) // simulate strchrnul()
325-
eol = buf + strlen(buf);
323+
const char *eol = strchrnul(buf, '\n');
326324
return xmemdupz(buf, eol - buf);
327325
}
328326

0 commit comments

Comments
 (0)