From: Erik Faye-Lund <kusmabite@gmail.com>
To: avarab@gmail.com
Cc: git@vger.kernel.org, Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH] gettext: use libcharset when available
Date: Tue, 28 Sep 2010 18:05:26 +0200 [thread overview]
Message-ID: <1285689926-5048-1-git-send-email-kusmabite@gmail.com> (raw)
libcharset provides an even more portable way of quering the charset
of the current locale.
Use that instead of nl_langinfo unless NO_LIBCHARSET is set.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
Windows doesn't have langinfo.h and nl_langinfo(), but libcharset was
invented for this very purpose. With this patch on top, ab/i18n
compiles without errors in msysGit.
There's still a bunch of lower-level issues on Windows, like gettext
ending up overloading our winansi-wrappings for printf and friends,
but let's take thinks one step at the time :)
configure.ac | 6 ++++++
gettext.c | 10 +++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1821d89..d3139cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -810,6 +810,12 @@ AC_CHECK_HEADER([libintl.h],
[NO_GETTEXT=YesPlease])
AC_SUBST(NO_GETTEXT)
#
+# Define NO_LIBCHARSET if you don't have libcharset.h
+AC_CHECK_HEADER([libcharset.h],
+[NO_LIBCHARSET=],
+[NO_LIBCHARSET=YesPlease])
+AC_SUBST(NO_LIBCHARSET)
+#
# Define NO_STRCASESTR if you don't have strcasestr.
GIT_CHECK_FUNC(strcasestr,
[NO_STRCASESTR=],
diff --git a/gettext.c b/gettext.c
index 8644098..902268c 100644
--- a/gettext.c
+++ b/gettext.c
@@ -1,13 +1,17 @@
#include "exec_cmd.h"
#include <locale.h>
#include <libintl.h>
+#ifndef NO_LIBCHARSET
+#include <libcharset.h>
+#else
#include <langinfo.h>
+#endif
#include <stdlib.h>
extern void git_setup_gettext(void) {
char *podir;
char *envdir = getenv("GIT_TEXTDOMAINDIR");
- char *charset;
+ const char *charset;
if (envdir) {
(void)bindtextdomain("git", envdir);
@@ -20,7 +24,11 @@ extern void git_setup_gettext(void) {
(void)setlocale(LC_MESSAGES, "");
(void)setlocale(LC_CTYPE, "");
+#ifndef NO_LIBCHARSET
+ charset = locale_charset();
+#else
charset = nl_langinfo(CODESET);
+#endif
(void)bind_textdomain_codeset("git", charset);
(void)setlocale(LC_CTYPE, "C");
(void)textdomain("git");
--
1.7.3.165.gdfe39.dirty
next reply other threads:[~2010-09-28 16:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-28 16:05 Erik Faye-Lund [this message]
2010-09-28 17:07 ` [PATCH] gettext: use libcharset when available Ævar Arnfjörð Bjarmason
2010-09-28 17:42 ` Erik Faye-Lund
2010-09-28 18:29 ` [PATCH/RFC 0/2] use libcharset.h with gettext if available Ævar Arnfjörð Bjarmason
2010-09-28 21:47 ` Erik Faye-Lund
2010-09-29 10:00 ` Ævar Arnfjörð Bjarmason
2010-09-29 11:41 ` Erik Faye-Lund
2010-09-29 13:07 ` [PATCH] gettext: use libcharset when available Ævar Arnfjörð Bjarmason
2010-09-29 13:34 ` Erik Faye-Lund
2010-09-29 13:40 ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2010-09-29 13:43 ` [PATCH v3] " Ævar Arnfjörð Bjarmason
2010-09-28 18:29 ` [PATCH/RFC 1/2] gettext: use const char* instead of char* Ævar Arnfjörð Bjarmason
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=1285689926-5048-1-git-send-email-kusmabite@gmail.com \
--to=kusmabite@gmail.com \
--cc=avarab@gmail.com \
--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).