summaryrefslogtreecommitdiff
path: root/gettext.h
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2012-09-04 10:39:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-14 19:45:50 (GMT)
commit754395d3052fc0d46948b2ff7006b3c6701785c8 (patch)
tree501893fca3b18e917ba9ff9ca5a807d2353b4d64 /gettext.h
parentb52183179bb0a97ea4d91d1248aca303d8e8f892 (diff)
downloadgit-754395d3052fc0d46948b2ff7006b3c6701785c8.zip
git-754395d3052fc0d46948b2ff7006b3c6701785c8.tar.gz
git-754395d3052fc0d46948b2ff7006b3c6701785c8.tar.bz2
fetch: align per-ref summary report in UTF-8 locales
fetch does printf("%-*s", width, "foo") where "foo" can be a utf-8 string, but width is in bytes, not columns. For ASCII it's fine as one byte takes one column. For utf-8, this may result in misaligned ref summary table. Introduce gettext_width() function that returns the string length in columns (currently only supports utf-8 locales). Make the code use TRANSPORT_SUMMARY(x) where the length is compensated properly in non-English locales. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gettext.h')
-rw-r--r--gettext.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gettext.h b/gettext.h
index 57ba8bb..e44d8bc 100644
--- a/gettext.h
+++ b/gettext.h
@@ -30,10 +30,15 @@
#ifndef NO_GETTEXT
extern void git_setup_gettext(void);
+extern int gettext_width(const char *s);
#else
static inline void git_setup_gettext(void)
{
}
+static inline int gettext_width(const char *s)
+{
+ return strlen(s);
+}
#endif
#ifdef GETTEXT_POISON