summaryrefslogtreecommitdiff
path: root/locale
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-08-05 23:36:21 +0000
committerUlrich Drepper <drepper@redhat.com>1997-08-05 23:36:21 +0000
commit044b16f4e9ae773187f4fee8a9a0a54f9a51f13f (patch)
tree58bc41e16535e0d0f61d51e6af15ce4128864fc9 /locale
parentc59a94711c6a9d38811b828863076f39000831b4 (diff)
update for 2.0.5pre1
Diffstat (limited to 'locale')
-rw-r--r--locale/programs/locale.c38
-rw-r--r--locale/programs/localedef.c7
-rw-r--r--locale/programs/locfile.c36
-rw-r--r--locale/setlocale.c12
4 files changed, 70 insertions, 23 deletions
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 7accb77019..d5b362c8c2 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -205,13 +205,13 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
/* `-a' requests the names of all available locales. */
if (do_all != 0)
{
- setlocale (LC_ALL, "");
+ setlocale (LC_COLLATE, "");
write_locales ();
exit (EXIT_SUCCESS);
}
/* `m' requests the names of all available charmaps. The names can be
- used for the -f argument to localedef(3). */
+ used for the -f argument to localedef(1). */
if (do_charmaps != 0)
{
write_charmaps ();
@@ -509,6 +509,25 @@ show_locale_vars (void)
}
+/* Some of the "string" we print contain non-printable characters. We
+ encode them here. */
+static void
+print_escaped (const char *string)
+{
+ const unsigned char *ch;
+
+ ch = string;
+ while ('\0' != *ch)
+ {
+ if (isprint (*ch))
+ putchar (*ch);
+ else
+ printf("<0x%02x>", *ch);
+ ++ch;
+ }
+}
+
+
/* Show the information request for NAME. */
static void
show_info (const char *name)
@@ -523,9 +542,11 @@ show_info (const char *name)
switch (item->value_type)
{
case string:
- printf ("%s%s%s", show_keyword_name ? "\"" : "",
- nl_langinfo (item->item_id) ? : "",
- show_keyword_name ? "\"" : "");
+ if (show_keyword_name)
+ putchar ('"');
+ print_escaped (nl_langinfo (item->item_id) ? : "");
+ if (show_keyword_name)
+ putchar ('"');
break;
case stringarray:
{
@@ -538,11 +559,14 @@ show_info (const char *name)
for (cnt = 0; cnt < item->max - 1; ++cnt)
{
val = nl_langinfo (item->item_id + cnt);
- printf ("%s;", val ? : "");
+ if (val != NULL)
+ print_escaped (val);
+ putchar (';');
}
val = nl_langinfo (item->item_id + cnt);
- printf ("%s", val ? : "");
+ if (val != NULL)
+ print_escaped (val);
if (show_keyword_name)
putchar ('"');
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index d64af771fe..f420400c7d 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -255,8 +255,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
{
avail = act_add_locdef->locale->categories[cat].generic != NULL;
if (avail)
- localedef->categories[cat].generic
- = act_add_locdef->locale->categories[cat].generic;
+ {
+ localedef->categories[cat].generic
+ = act_add_locdef->locale->categories[cat].generic;
+ localedef->avail |= 1 << cat;
+ }
}
if (! avail)
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
index aecc8913e2..7749f6aebc 100644
--- a/locale/programs/locfile.c
+++ b/locale/programs/locfile.c
@@ -920,17 +920,23 @@ void
check_all_categories (struct localedef_t *locale, struct charset_t *charset)
{
/* Call the finishing functions for all locales. */
- if ((locale->binary & (1 << LC_CTYPE)) == 0)
+ if ((locale->avail & (1 << LC_CTYPE)) != 0
+ && (locale->binary & (1 << LC_CTYPE)) == 0)
ctype_finish (locale, charset);
- if ((locale->binary & (1 << LC_COLLATE)) == 0)
+ if ((locale->avail & (1 << LC_COLLATE)) != 0
+ && (locale->binary & (1 << LC_COLLATE)) == 0)
collate_finish (locale, charset);
- if ((locale->binary & (1 << LC_MONETARY)) == 0)
+ if ((locale->avail & (1 << LC_MONETARY)) != 0
+ && (locale->binary & (1 << LC_MONETARY)) == 0)
monetary_finish (locale);
- if ((locale->binary & (1 << LC_NUMERIC)) == 0)
+ if ((locale->avail & (1 << LC_NUMERIC)) != 0
+ && (locale->binary & (1 << LC_NUMERIC)) == 0)
numeric_finish (locale);
- if ((locale->binary & (1 << LC_TIME)) == 0)
+ if ((locale->avail & (1 << LC_TIME)) != 0
+ && (locale->binary & (1 << LC_TIME)) == 0)
time_finish (locale);
- if ((locale->binary & (1 << LC_MESSAGES)) == 0)
+ if ((locale->avail & (1 << LC_MESSAGES)) != 0
+ && (locale->binary & (1 << LC_MESSAGES)) == 0)
messages_finish (locale);
}
@@ -940,12 +946,18 @@ write_all_categories (struct localedef_t *locale, struct charset_t *charset,
const char *output_path)
{
/* Call all functions to write locale data. */
- ctype_output (locale, charset, output_path);
- collate_output (locale, charset, output_path);
- monetary_output (locale, output_path);
- numeric_output (locale, output_path);
- time_output (locale, output_path);
- messages_output (locale, output_path);
+ if ((locale->avail & (1 << LC_CTYPE)) != 0)
+ ctype_output (locale, charset, output_path);
+ if ((locale->avail & (1 << LC_COLLATE)) != 0)
+ collate_output (locale, charset, output_path);
+ if ((locale->avail & (1 << LC_MONETARY)) != 0)
+ monetary_output (locale, output_path);
+ if ((locale->avail & (1 << LC_NUMERIC)) != 0)
+ numeric_output (locale, output_path);
+ if ((locale->avail & (1 << LC_TIME)) != 0)
+ time_output (locale, output_path);
+ if ((locale->avail & (1 << LC_MESSAGES)) != 0)
+ messages_output (locale, output_path);
}
diff --git a/locale/setlocale.c b/locale/setlocale.c
index 70a5007ee5..4fc5512ecb 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -204,8 +204,10 @@ new_composite_name (int category, char *newnames[LC_ALL])
static inline void
setname (int category, const char *name)
{
- if (_nl_current[category] == NULL
- && _nl_current_names[category] != _nl_C_name)
+ if (_nl_current_names[category] == name)
+ return;
+
+ if (_nl_current_names[category] != _nl_C_name)
free ((void *) _nl_current_names[category]);
_nl_current_names[category] = name;
@@ -355,6 +357,9 @@ setlocale (int category, const char *locale)
/* Critical section left. */
__libc_lock_unlock (__libc_setlocale_lock);
+ /* Free the resources (the locale path variable. */
+ free (locale_path);
+
return composite;
}
else
@@ -394,6 +399,9 @@ setlocale (int category, const char *locale)
/* Critical section left. */
__libc_lock_unlock (__libc_setlocale_lock);
+ /* Free the resources (the locale path variable. */
+ free (locale_path);
+
return newname;
}
}