Skip to contentSkip to conversation

pretty: use starts_with() to check for a prefix

PATCH New René Scharfe 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pretty: use starts_with() to check for a prefix

Simplify the code and avoid duplication by using starts_with() instead of strlen() and strncmp() to check if a line starts with "encoding ".

---
 pretty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
pretty.c +1 -1
index 9d34d02..7b49304 100644
@@ -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;
Signature · 1 line
2.3.0