summaryrefslogtreecommitdiff
path: root/libc/locale
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2008-08-19 17:24:09 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2008-08-19 17:24:09 +0000
commit447fd9179ef3effda7c99168c310c5e0d0e8e770 (patch)
treef90fa016ce2e15d5b509f124107ea12273ee605e /libc/locale
parent46a638ad529cc323bb7fbd02968b0770ab6626e8 (diff)
Merge changes between r6509 and r6780 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@6785 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/locale')
-rw-r--r--libc/locale/setlocale.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/libc/locale/setlocale.c b/libc/locale/setlocale.c
index 0ff7167be..9593483d9 100644
--- a/libc/locale/setlocale.c
+++ b/libc/locale/setlocale.c
@@ -163,7 +163,7 @@ new_composite_name (int category, const char *newnames[__LC_LAST])
/* Put NAME in _nl_global_locale.__names. */
-static inline void
+static void
setname (int category, const char *name)
{
if (_nl_global_locale.__names[category] == name)
@@ -204,9 +204,16 @@ setlocale (int category, const char *locale)
if (locale == NULL)
return (char *) _nl_global_locale.__names[category];
+ /* Protect global data. */
+ __libc_rwlock_wrlock (__libc_setlocale_lock);
+
if (strcmp (locale, _nl_global_locale.__names[category]) == 0)
- /* Changing to the same thing. */
- return (char *) _nl_global_locale.__names[category];
+ {
+ /* Changing to the same thing. */
+ __libc_rwlock_unlock (__libc_setlocale_lock);
+
+ return (char *) _nl_global_locale.__names[category];
+ }
/* We perhaps really have to load some data. So we determine the
path in which to look for the data now. The environment variable
@@ -220,12 +227,13 @@ setlocale (int category, const char *locale)
if (locpath_var != NULL && locpath_var[0] != '\0')
{
if (__argz_create_sep (locpath_var, ':',
- &locale_path, &locale_path_len) != 0)
- return NULL;
-
- if (__argz_add_sep (&locale_path, &locale_path_len,
- _nl_default_locale_path, ':') != 0)
- return NULL;
+ &locale_path, &locale_path_len) != 0
+ || __argz_add_sep (&locale_path, &locale_path_len,
+ _nl_default_locale_path, ':') != 0)
+ {
+ __libc_rwlock_unlock (__libc_setlocale_lock);
+ return NULL;
+ }
}
if (category == LC_ALL)
@@ -260,8 +268,13 @@ setlocale (int category, const char *locale)
break;
if (cnt == __LC_LAST)
- /* Bogus category name. */
- ERROR_RETURN;
+ {
+ error_return:
+ __libc_rwlock_unlock (__libc_setlocale_lock);
+
+ /* Bogus category name. */
+ ERROR_RETURN;
+ }
/* Found the category this clause sets. */
newnames[cnt] = ++cp;
@@ -280,12 +293,9 @@ setlocale (int category, const char *locale)
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL && newnames[cnt] == locale)
/* The composite name did not specify all categories. */
- ERROR_RETURN;
+ goto error_return;
}
- /* Protect global data. */
- __libc_rwlock_wrlock (__libc_setlocale_lock);
-
/* Load the new data for each category. */
while (category-- > 0)
if (category != LC_ALL)
@@ -363,9 +373,6 @@ setlocale (int category, const char *locale)
struct locale_data *newdata = NULL;
const char *newname[1] = { locale };
- /* Protect global data. */
- __libc_rwlock_wrlock (__libc_setlocale_lock);
-
if (CATEGORY_USED (category))
{
/* Only actually load the data if anything will use it. */