threads / patch / 38626

patchpretty: use starts_with() to check for a prefix

Subject: [PATCH] pretty: use starts_with() to check for a prefix

## tl;dr

One message between Feb 21, 2015 and Feb 21, 2015. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

René Scharfe· Feb 21, 2015, 19:53 UTC · lore

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(-)
Show changes to pretty.c +1 −1
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

← back to recent threads