summaryrefslogtreecommitdiff
path: root/locale
diff options
context:
space:
mode:
Diffstat (limited to 'locale')
-rw-r--r--locale/C_name.c1
-rw-r--r--locale/findlocale.c5
-rw-r--r--locale/localeinfo.h3
-rw-r--r--locale/setlocale.c30
4 files changed, 15 insertions, 24 deletions
diff --git a/locale/C_name.c b/locale/C_name.c
index 5e7cb85a09..fa2ac0539c 100644
--- a/locale/C_name.c
+++ b/locale/C_name.c
@@ -5,3 +5,4 @@
/* Name of our standard locale. */
const char _nl_C_name[] = "C";
+const char _nl_POSIX_name[] = "POSIX";
diff --git a/locale/findlocale.c b/locale/findlocale.c
index 308aa2b60f..c027968530 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -64,7 +64,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
*name = (char *) _nl_C_name;
}
- if (strcmp (*name, _nl_C_name) == 0 || strcmp (*name, "POSIX") == 0)
+ if (strcmp (*name, _nl_C_name) == 0 || strcmp (*name, _nl_POSIX_name) == 0)
{
/* We need not load anything. The needed data is contained in
the library itself. */
@@ -203,6 +203,9 @@ _nl_remove_locale (int locale, struct locale_data *data)
ptr->decided = 0;
ptr->data = NULL;
+ /* Free the name. */
+ free ((char *) data->name);
+
/* Really delete the data. First delete the real data. */
if (data->mmaped)
{
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index 79db06d2f5..29731fa4c6 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -107,8 +107,9 @@ extern const char *const _nl_category_names[LC_ALL + 1];
extern const size_t _nl_category_name_sizes[LC_ALL + 1];
extern struct locale_data * *const _nl_current[LC_ALL + 1];
-/* Name of the standard locale. */
+/* Name of the standard locales. */
extern const char _nl_C_name[];
+extern const char _nl_POSIX_name[];
/* Extract the current CATEGORY locale's string for ITEM. */
#define _NL_CURRENT(category, item) \
diff --git a/locale/setlocale.c b/locale/setlocale.c
index 79f15ccb40..42c1e5033a 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -130,24 +130,6 @@ __libc_lock_define_initialized (, __libc_setlocale_lock)
} while (0)
-static inline char *
-clever_copy (const char *string)
-{
- size_t len;
- char *new;
-
- if (strcmp (string, "C") == 0 || strcmp (string, "POSIX") == 0)
- /* This return is dangerous because the returned string might be
- placed in read-only memory. But everything should be set up to
- handle this case. */
- return (char *) _nl_C_name;
-
- len = strlen (string) + 1;
- new = (char *) malloc (len);
- return new != NULL ? memcpy (new, string, len) : NULL;
-}
-
-
/* Construct a new composite name. */
static inline char *
new_composite_name (int category, const char *newnames[LC_ALL])
@@ -172,7 +154,8 @@ new_composite_name (int category, const char *newnames[LC_ALL])
if (same)
{
/* All the categories use the same name. */
- if (strcmp (newnames[0], "C") == 0 || strcmp (newnames[0], "POSIX") == 0)
+ if (strcmp (newnames[0], _nl_C_name) == 0
+ || strcmp (newnames[0], _nl_POSIX_name) == 0)
return (char *) _nl_C_name;
new = malloc (last_len + 1);
@@ -207,8 +190,8 @@ setname (int category, const char *name)
if (_nl_current_names[category] == name)
return;
- if (_nl_current_names[category] != _nl_C_name)
- free ((void *) _nl_current_names[category]);
+ if (category == LC_ALL && _nl_current_names[category] != _nl_C_name)
+ free ((char *) _nl_current_names[category]);
_nl_current_names[category] = name;
}
@@ -375,7 +358,10 @@ setlocale (int category, const char *locale)
goto abort_single;
/* We must not simply free a global locale since we have no
- control over the usage. So we mark it as un-deletable. */
+ control over the usage. So we mark it as un-deletable.
+
+ Note: do ont remove the `if', it's necessary to copy with
+ the builtin locale data. */
if (newdata->usage_count != MAX_USAGE_COUNT)
newdata->usage_count = MAX_USAGE_COUNT;
}