mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-21 04:00:19 +02:00
Revert changes that gather thread-specific local language
The method used was not portable. However, the underlying problem still exists: the uc_locale_language used by libunistring does not work with thread-specific locale_t locales. * libguile/i18n.c (locale_language): avoid unpacking semi-opaque type locale_t. * test-suite/tests/i18n.test: set Turkish string and char locale upcase and downcase tests to throw untested
This commit is contained in:
parent
3d1af79fec
commit
03d80c0327
2 changed files with 20 additions and 35 deletions
|
@ -779,44 +779,17 @@ compare_u32_strings (SCM s1, SCM s2, SCM locale, const char *func_name)
|
||||||
static const char *
|
static const char *
|
||||||
locale_language ()
|
locale_language ()
|
||||||
{
|
{
|
||||||
#ifdef USE_GNU_LOCALE_API
|
/* FIXME: If the locale has been set with 'uselocale',
|
||||||
{
|
libunistring's uc_locale_language will return the incorrect
|
||||||
static char lang[10];
|
language: it will return the language appropriate for the global
|
||||||
scm_t_locale loc;
|
(non-thread-specific) locale.
|
||||||
const char *c_result;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
/* If we are here, the locale has been set with 'uselocale'. We
|
There appears to be no portable way to extract the language from
|
||||||
can't use libunistring's uc_locale_language because it calls
|
the thread-specific locale_t. There is no LANGUAGE capability in
|
||||||
setlocale. */
|
nl_langinfo or nl_langinfo_l.
|
||||||
loc = uselocale (0);
|
|
||||||
if (loc == (scm_t_locale) -1)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
/* The internal structure of locale_t may be specific to the C
|
Thus, uc_locale_language needs to be fixed upstream. */
|
||||||
library, but, there doesn't seem to be any other way to extract
|
|
||||||
the locale name. */
|
|
||||||
c_result = loc->__names[LC_CTYPE];
|
|
||||||
p = (char *) c_result;
|
|
||||||
while (*p != '\0' && *p != '_' && *p != '.' && *p != '@')
|
|
||||||
p++;
|
|
||||||
|
|
||||||
/* Return a statically allocated pointer to the language portion,
|
|
||||||
so that the caller of this function does not need to free() the
|
|
||||||
result. */
|
|
||||||
if (p != c_result)
|
|
||||||
{
|
|
||||||
memcpy (lang, c_result, p - c_result);
|
|
||||||
lang[p - c_result] = '\0';
|
|
||||||
return lang;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* The locale has been set with setlocale. */
|
|
||||||
return uc_locale_language ();
|
return uc_locale_language ();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
|
@ -205,11 +205,17 @@
|
||||||
(pass-if "char-locale-upcase Turkish"
|
(pass-if "char-locale-upcase Turkish"
|
||||||
(under-turkish-utf8-locale-or-unresolved
|
(under-turkish-utf8-locale-or-unresolved
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
;; This test is disabled for now, because char-locale-upcase is
|
||||||
|
;; incomplete.
|
||||||
|
(throw 'untested)
|
||||||
(eq? #\İ (char-locale-upcase #\i %turkish-utf8-locale)))))
|
(eq? #\İ (char-locale-upcase #\i %turkish-utf8-locale)))))
|
||||||
|
|
||||||
(pass-if "char-locale-downcase Turkish"
|
(pass-if "char-locale-downcase Turkish"
|
||||||
(under-turkish-utf8-locale-or-unresolved
|
(under-turkish-utf8-locale-or-unresolved
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
;; This test is disabled for now, because char-locale-downcase
|
||||||
|
;; is incomplete.
|
||||||
|
(throw 'untested)
|
||||||
(eq? #\i (char-locale-downcase #\İ %turkish-utf8-locale))))))
|
(eq? #\i (char-locale-downcase #\İ %turkish-utf8-locale))))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,11 +232,17 @@
|
||||||
(pass-if "string-locale-upcase Turkish"
|
(pass-if "string-locale-upcase Turkish"
|
||||||
(under-turkish-utf8-locale-or-unresolved
|
(under-turkish-utf8-locale-or-unresolved
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
;; This test is disabled for now, because string-locale-upcase
|
||||||
|
;; is incomplete.
|
||||||
|
(throw 'untested)
|
||||||
(string=? "İI" (string-locale-upcase "iı" %turkish-utf8-locale)))))
|
(string=? "İI" (string-locale-upcase "iı" %turkish-utf8-locale)))))
|
||||||
|
|
||||||
(pass-if "string-locale-downcase Turkish"
|
(pass-if "string-locale-downcase Turkish"
|
||||||
(under-turkish-utf8-locale-or-unresolved
|
(under-turkish-utf8-locale-or-unresolved
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
;; This test is disabled for now, because
|
||||||
|
;; string-locale-downcase is incomplete.
|
||||||
|
(throw 'untested)
|
||||||
(string=? "iı" (string-locale-downcase "İI" %turkish-utf8-locale))))))
|
(string=? "iı" (string-locale-downcase "İI" %turkish-utf8-locale))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue