[PATCH 2/3] pretty: simplify output line length calculation in pp_user_info()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Keep namelen unchanged and don't use it to hold a value that we're not
interested in anyway -- we can use maillen and the constant part
directly instead.  This simplifies the code slightly and prepares for
the next patch that makes use of the original value of namelen.

Signed-off-by: Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx>
---
 pretty.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/pretty.c b/pretty.c
index e51c993..6861997 100644
--- a/pretty.c
+++ b/pretty.c
@@ -439,8 +439,6 @@ void pp_user_info(const struct pretty_print_context *pp,
 	strbuf_add(&mail, mailbuf, maillen);
 	strbuf_add(&name, namebuf, namelen);
 
-	namelen = name.len + mail.len + 3; /* ' ' + '<' + '>' */
-
 	if (pp->fmt == CMIT_FMT_EMAIL) {
 		strbuf_addstr(sb, "From: ");
 		if (needs_rfc2047_encoding(name.buf, name.len, RFC2047_ADDRESS)) {
@@ -457,9 +455,10 @@ void pp_user_info(const struct pretty_print_context *pp,
 			strbuf_add_wrapped_bytes(sb, name.buf, name.len,
 						 -6, 1, max_length);
 		}
-		if (namelen - name.len + last_line_length(sb) > max_length)
-			strbuf_addch(sb, '\n');
 
+		if (max_length <
+		    last_line_length(sb) + strlen(" <") + maillen + strlen(">"))
+			strbuf_addch(sb, '\n');
 		strbuf_addf(sb, " <%s>\n", mail.buf);
 	} else {
 		strbuf_addf(sb, "%s: %.*s%s <%s>\n", what,
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]