Skip to content

Commit 74c91d1

Browse files
committed
Merge branch 'ye/http-accept-language'
Compilation fix for a recent topic in 'master'. * ye/http-accept-language: gettext.c: move get_preferred_languages() from http.c
2 parents 2588882 + 93f7d91 commit 74c91d1

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

gettext.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,31 @@
1818
# endif
1919
#endif
2020

21+
/*
22+
* Guess the user's preferred languages from the value in LANGUAGE environment
23+
* variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
24+
*
25+
* The result can be a colon-separated list like "ko:ja:en".
26+
*/
27+
const char *get_preferred_languages(void)
28+
{
29+
const char *retval;
30+
31+
retval = getenv("LANGUAGE");
32+
if (retval && *retval)
33+
return retval;
34+
35+
#ifndef NO_GETTEXT
36+
retval = setlocale(LC_MESSAGES, NULL);
37+
if (retval && *retval &&
38+
strcmp(retval, "C") &&
39+
strcmp(retval, "POSIX"))
40+
return retval;
41+
#endif
42+
43+
return NULL;
44+
}
45+
2146
#ifdef GETTEXT_POISON
2247
int use_gettext_poison(void)
2348
{

gettext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
8989
#define N_(msgid) (msgid)
9090
#endif
9191

92+
const char *get_preferred_languages(void);
93+
9294
#endif

http.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "credential.h"
99
#include "version.h"
1010
#include "pkt-line.h"
11+
#include "gettext.h"
1112

1213
int active_requests;
1314
int http_is_verbose;
@@ -1002,32 +1003,6 @@ static void extract_content_type(struct strbuf *raw, struct strbuf *type,
10021003
strbuf_addstr(charset, "ISO-8859-1");
10031004
}
10041005

1005-
1006-
/*
1007-
* Guess the user's preferred languages from the value in LANGUAGE environment
1008-
* variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
1009-
*
1010-
* The result can be a colon-separated list like "ko:ja:en".
1011-
*/
1012-
static const char *get_preferred_languages(void)
1013-
{
1014-
const char *retval;
1015-
1016-
retval = getenv("LANGUAGE");
1017-
if (retval && *retval)
1018-
return retval;
1019-
1020-
#ifndef NO_GETTEXT
1021-
retval = setlocale(LC_MESSAGES, NULL);
1022-
if (retval && *retval &&
1023-
strcmp(retval, "C") &&
1024-
strcmp(retval, "POSIX"))
1025-
return retval;
1026-
#endif
1027-
1028-
return NULL;
1029-
}
1030-
10311006
static void write_accept_language(struct strbuf *buf)
10321007
{
10331008
/*

0 commit comments

Comments
 (0)