diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-01-03 04:01:43 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-01-03 04:01:43 +0000 |
commit | 3859d27d73f37877d0633092ab003e0bf2753b13 (patch) | |
tree | f0a2e47d4cc512127ff6253f271318cfef32e11f | |
parent | 1dc72e4ffeddaad3982c8ea7978aba99f63867a4 (diff) | |
download | glibc-3859d27d73f37877d0633092ab003e0bf2753b13.zip glibc-3859d27d73f37877d0633092ab003e0bf2753b13.tar.gz glibc-3859d27d73f37877d0633092ab003e0bf2753b13.tar.bz2 |
(guess_category_value): Rewrite so that LANGUAGE value is ignored if the selected locale is the C locale.
-rw-r--r-- | intl/dcigettext.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/intl/dcigettext.c b/intl/dcigettext.c index dd3a559..8712e4b 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -1071,39 +1071,41 @@ guess_category_value (category, categoryname) int category; const char *categoryname; { + const char *language; const char *retval; /* The highest priority value is the `LANGUAGE' environment - variable. This is a GNU extension. */ - retval = getenv ("LANGUAGE"); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* `LANGUAGE' is not set. So we have to proceed with the POSIX - methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some - systems this can be done by the `setlocale' function itself. */ + variable. But we don't use the value if the currently selected + locale is the C locale. This is a GNU extension. */ + language = getenv ("LANGUAGE"); + if (language != NULL && language[0] == '\0') + language = NULL; + + /* We have to proceed with the POSIX methods of looking to `LC_ALL', + `LC_xxx', and `LANG'. On some systems this can be done by the + `setlocale' function itself. */ #if defined _LIBC || (defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL) - return setlocale (category, NULL); + retval = setlocale (category, NULL); #else /* Setting of LC_ALL overwrites all other. */ retval = getenv ("LC_ALL"); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* Next comes the name of the desired category. */ - retval = getenv (categoryname); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* Last possibility is the LANG environment variable. */ - retval = getenv ("LANG"); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* We use C as the default domain. POSIX says this is implementation - defined. */ - return "C"; + if (retval == NULL || retval[0] == '\0') + { + /* Next comes the name of the desired category. */ + retval = getenv (categoryname); + if (retval == NULL || retval[0] == '\0') + { + /* Last possibility is the LANG environment variable. */ + retval = getenv ("LANG"); + if (retval == NULL || retval[0] == '\0') + /* We use C as the default domain. POSIX says this is + implementation defined. */ + return "C"; + } + } #endif + + return language != NULL && strcmp (retval, "C") != 0 ? language : retval; } /* @@ begin of epilog @@ */ |