mirror of git://sourceware.org/git/glibc.git
(guess_category_value): Rewrite so that LANGUAGE value is ignored if the selected locale is the C locale.
This commit is contained in:
parent
1dc72e4ffe
commit
3859d27d73
|
|
@ -1071,39 +1071,41 @@ guess_category_value (category, categoryname)
|
||||||
int category;
|
int category;
|
||||||
const char *categoryname;
|
const char *categoryname;
|
||||||
{
|
{
|
||||||
|
const char *language;
|
||||||
const char *retval;
|
const char *retval;
|
||||||
|
|
||||||
/* The highest priority value is the `LANGUAGE' environment
|
/* The highest priority value is the `LANGUAGE' environment
|
||||||
variable. This is a GNU extension. */
|
variable. But we don't use the value if the currently selected
|
||||||
retval = getenv ("LANGUAGE");
|
locale is the C locale. This is a GNU extension. */
|
||||||
if (retval != NULL && retval[0] != '\0')
|
language = getenv ("LANGUAGE");
|
||||||
return retval;
|
if (language != NULL && language[0] == '\0')
|
||||||
|
language = NULL;
|
||||||
|
|
||||||
/* `LANGUAGE' is not set. So we have to proceed with the POSIX
|
/* We have to proceed with the POSIX methods of looking to `LC_ALL',
|
||||||
methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
|
`LC_xxx', and `LANG'. On some systems this can be done by the
|
||||||
systems this can be done by the `setlocale' function itself. */
|
`setlocale' function itself. */
|
||||||
#if defined _LIBC || (defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL)
|
#if defined _LIBC || (defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL)
|
||||||
return setlocale (category, NULL);
|
retval = setlocale (category, NULL);
|
||||||
#else
|
#else
|
||||||
/* Setting of LC_ALL overwrites all other. */
|
/* Setting of LC_ALL overwrites all other. */
|
||||||
retval = getenv ("LC_ALL");
|
retval = getenv ("LC_ALL");
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval == NULL || retval[0] == '\0')
|
||||||
return retval;
|
{
|
||||||
|
|
||||||
/* Next comes the name of the desired category. */
|
/* Next comes the name of the desired category. */
|
||||||
retval = getenv (categoryname);
|
retval = getenv (categoryname);
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval == NULL || retval[0] == '\0')
|
||||||
return retval;
|
{
|
||||||
|
|
||||||
/* Last possibility is the LANG environment variable. */
|
/* Last possibility is the LANG environment variable. */
|
||||||
retval = getenv ("LANG");
|
retval = getenv ("LANG");
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval == NULL || retval[0] == '\0')
|
||||||
return retval;
|
/* We use C as the default domain. POSIX says this is
|
||||||
|
implementation defined. */
|
||||||
/* We use C as the default domain. POSIX says this is implementation
|
|
||||||
defined. */
|
|
||||||
return "C";
|
return "C";
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return language != NULL && strcmp (retval, "C") != 0 ? language : retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @@ begin of epilog @@ */
|
/* @@ begin of epilog @@ */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue