Skip to content

Commit

Permalink
pretty: use starts_with() to check for a prefix
Browse files Browse the repository at this point in the history
Simplify the code and avoid duplication by using starts_with() instead
of strlen() and strncmp() to check if a line starts with "encoding ".

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Feb 22, 2015
1 parent 008d5d0 commit 68d6d6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
char *cp = buf;

/* guess if there is an encoding header before a \n\n */
while (strncmp(cp, "encoding ", strlen("encoding "))) {
while (!starts_with(cp, "encoding ")) {
cp = strchr(cp, '\n');
if (!cp || *++cp == '\n')
return buf;
Expand Down

0 comments on commit 68d6d6e

Please sign in to comment.