Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Mar 6, 2015
2 parents 2588882 + 93f7d91 commit 74c91d1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
25 changes: 25 additions & 0 deletions gettext.c
Expand Up @@ -18,6 +18,31 @@
# 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)
{
Expand Down
2 changes: 2 additions & 0 deletions gettext.h
Expand Up @@ -89,4 +89,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
#define N_(msgid) (msgid)
#endif

const char *get_preferred_languages(void);

#endif
27 changes: 1 addition & 26 deletions http.c
Expand Up @@ -8,6 +8,7 @@
#include "credential.h"
#include "version.h"
#include "pkt-line.h"
#include "gettext.h"

int active_requests;
int http_is_verbose;
Expand Down Expand Up @@ -1002,32 +1003,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)
{
/*
Expand Down

0 comments on commit 74c91d1

Please sign in to comment.