git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pretty: use starts_with() to check for a prefix
@ 2015-02-21 19:53 René Scharfe
  0 siblings, 0 replies; only message in thread
From: René Scharfe @ 2015-02-21 19:53 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

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>
---
 pretty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pretty.c b/pretty.c
index 9d34d02..7b49304 100644
--- a/pretty.c
+++ b/pretty.c
@@ -567,7 +567,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;
-- 
2.3.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-21 19:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-21 19:53 [PATCH] pretty: use starts_with() to check for a prefix René Scharfe

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).