gettext.c: move get_preferred_languages() from http.c
authorJeff King <peff@peff.net>
Thu, 26 Feb 2015 03:04:16 +0000 (22:04 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Feb 2015 22:09:20 +0000 (14:09 -0800)
Calling setlocale(LC_MESSAGES, ...) directly from http.c, without
including <locale.h>, was causing compilation warnings. Move the
helper function to gettext.c that already includes the header and
where locale-related issues are handled.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gettext.c
gettext.h
http.c
index 8b2da4641f8b20ff3cc70c63636de878eec72470..7378ba287f0c449810250fb7b019f69e4f6a3497 100644 (file)
--- a/gettext.c
+++ b/gettext.c
 #      endif
 #endif
 
+/*
+ * Guess the user's preferred languages from the value in LANGUAGE environment
+ * variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
+ *
+ * The result can be a colon-separated list like "ko:ja:en".
+ */
+const char *get_preferred_languages(void)
+{
+       const char *retval;
+
+       retval = getenv("LANGUAGE");
+       if (retval && *retval)
+               return retval;
+
+#ifndef NO_GETTEXT
+       retval = setlocale(LC_MESSAGES, NULL);
+       if (retval && *retval &&
+               strcmp(retval, "C") &&
+               strcmp(retval, "POSIX"))
+               return retval;
+#endif
+
+       return NULL;
+}
+
 #ifdef GETTEXT_POISON
 int use_gettext_poison(void)
 {
index 7671d09d04bb87541b11209b5cdbddbb9e4e59b8..e539482ae798d3c781c9d56cddd9f048d6b1badc 100644 (file)
--- a/gettext.h
+++ b/gettext.h
@@ -65,4 +65,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
 /* Mark msgid for translation but do not translate it. */
 #define N_(msgid) msgid
 
+const char *get_preferred_languages(void);
+
 #endif
diff --git a/http.c b/http.c
index 8b659b66963c38c84c498a0850105e68668b1e16..007b29b8bb4cf27b619467d69a88ef5c79db282d 100644 (file)
--- a/http.c
+++ b/http.c
@@ -8,6 +8,7 @@
 #include "credential.h"
 #include "version.h"
 #include "pkt-line.h"
+#include "gettext.h"
 
 int active_requests;
 int http_is_verbose;
@@ -991,31 +992,6 @@ static void extract_content_type(struct strbuf *raw, struct strbuf *type,
                strbuf_addstr(charset, "ISO-8859-1");
 }
 
-/*
- * Guess the user's preferred languages from the value in LANGUAGE environment
- * variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
- *
- * The result can be a colon-separated list like "ko:ja:en".
- */
-static const char *get_preferred_languages(void)
-{
-       const char *retval;
-
-       retval = getenv("LANGUAGE");
-       if (retval && *retval)
-               return retval;
-
-#ifndef NO_GETTEXT
-       retval = setlocale(LC_MESSAGES, NULL);
-       if (retval && *retval &&
-               strcmp(retval, "C") &&
-               strcmp(retval, "POSIX"))
-               return retval;
-#endif
-
-       return NULL;
-}
-
 static void write_accept_language(struct strbuf *buf)
 {
        /*