From: Geoffrey Thomas <geofft@MIT.EDU>
To: git@vger.kernel.org
Cc: Geoffrey Thomas <geofft@mit.edu>
Subject: [PATCH] builtin-blame.c: Use utf8_strwidth for author's names
Date: Fri, 30 Jan 2009 04:41:29 -0500 [thread overview]
Message-ID: <1233308489-2656-2-git-send-email-geofft@mit.edu> (raw)
In-Reply-To: <1233308489-2656-1-git-send-email-geofft@mit.edu>
From: Geoffrey Thomas <geofft@mit.edu>
git blame misaligns output if a author's name has a differing display width and
strlen; for instance, an accented Latin letter that takes two bytes to encode
will cause the rest of the line to be shifted to the left by one. To fix this,
use utf8_strwidth instead of strlen (and compute the padding ourselves, since
printf doesn't know about UTF-8).
Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
---
builtin-blame.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index aae14ef..2941fc0 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -19,6 +19,7 @@
#include "string-list.h"
#include "mailmap.h"
#include "parse-options.h"
+#include "utf8.h"
static char blame_usage[] = "git blame [options] [rev-opts] [rev] [--] file";
@@ -1619,9 +1620,9 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
ent->s_lno + 1 + cnt);
if (!(opt & OUTPUT_NO_AUTHOR))
- printf(" (%-*.*s %10s",
- longest_author, longest_author,
+ printf(" (%s%*s %10s",
ci.author,
+ longest_author - utf8_strwidth(ci.author), "",
format_time(ci.author_time,
ci.author_tz,
show_raw_time));
@@ -1755,7 +1756,7 @@ static void find_alignment(struct scoreboard *sb, int *option)
if (!(suspect->commit->object.flags & METAINFO_SHOWN)) {
suspect->commit->object.flags |= METAINFO_SHOWN;
get_commit_info(suspect->commit, &ci, 1);
- num = strlen(ci.author);
+ num = utf8_strwidth(ci.author);
if (longest_author < num)
longest_author = num;
}
--
1.5.6.5
next prev parent reply other threads:[~2009-01-30 9:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-30 9:41 [PATCH] utf8: add utf8_strwidth() Geoffrey Thomas
2009-01-30 9:41 ` Geoffrey Thomas [this message]
2009-01-30 17:12 ` [PATCH] builtin-blame.c: Use utf8_strwidth for author's names Johannes Schindelin
2009-01-30 22:22 ` Geoffrey Thomas
2009-01-31 7:24 ` Jeff King
2009-02-01 22:34 ` Johannes Schindelin
2009-02-02 6:48 ` Junio C Hamano
2009-02-02 12:40 ` Johannes Schindelin
2009-02-03 4:30 ` Junio C Hamano
2009-02-02 12:41 ` Jeff King
2009-01-31 7:17 ` [PATCH] utf8: add utf8_strwidth() Jeff King
2009-01-31 8:51 ` Geoffrey Thomas
2009-01-31 8:56 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1233308489-2656-2-git-send-email-geofft@mit.edu \
--to=geofft@mit.edu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).