This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: search locale archive again after alias expansion
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: Roland McGrath <roland at hack dot frob dot com>, libc-alpha at sourceware dot org
- Date: Fri, 27 Feb 2015 16:18:39 -0500
- Subject: Re: search locale archive again after alias expansion
- Authentication-results: sourceware.org; auth=none
- References: <orr4dao5h6 dot fsf at livre dot home> <20130918220004 dot B23492C09F at topped-with-meat dot com> <ory56t31yv dot fsf at livre dot home> <or8uigyac8 dot fsf at free dot home> <oregr8db48 dot fsf at livre dot home> <54E796D1 dot 40502 at redhat dot com> <oregpd19rz dot fsf at livre dot home> <54EF93B1 dot 60808 at redhat dot com> <orioenettk dot fsf at livre dot home> <54F0A592 dot 7090809 at redhat dot com> <orfv9rawye dot fsf at livre dot home>
On 02/27/2015 04:03 PM, Alexandre Oliva wrote:
> On Feb 27, 2015, "Carlos O'Donell" <carlos@redhat.com> wrote:
>
>> Is that minimal? Does that solve the casting issue?
>
> Of course not. Plenty of casts that drop const, now superfluous, remain
> in place with your patch. The point of the patch was to remove them
> all.
Now?
That is ~9 lines of changes vs. the original ~22 lines of change.
diff --git a/locale/findlocale.c b/locale/findlocale.c
index 5e2639b..2e98c31 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -105,7 +105,8 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
{
int mask;
/* Name of the locale for this category. */
- char *loc_name = (char *) *name;
+ const char *loc_name = *name;
+ char *loc_name_copy;
const char *language;
const char *modifier;
const char *territory;
@@ -124,7 +125,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
if (!name_present (loc_name))
loc_name = getenv ("LANG");
if (!name_present (loc_name))
- loc_name = (char *) _nl_C_name;
+ loc_name = _nl_C_name;
}
/* We used to fall back to the C locale if the name contains a slash
@@ -136,7 +137,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
{
/* We need not load anything. The needed data is contained in
the library itself. */
- *name = (char *) _nl_C_name;
+ *name = _nl_C_name;
return _nl_C[category];
}
else if (!valid_locale_name (loc_name))
@@ -158,11 +159,10 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
/* Nothing in the archive with the given name. Expanding it as
an alias and retry. */
- loc_name = (char *) _nl_expand_alias (*name);
+ loc_name = _nl_expand_alias (*name);
if (loc_name != NULL)
{
- data = _nl_load_locale_from_archive (category,
- (const char **) &loc_name);
+ data = _nl_load_locale_from_archive (category, &loc_name);
if (__builtin_expect (data != NULL, 1))
return data;
}
@@ -175,14 +175,14 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
/* We really have to load some data. First see whether the name is
an alias. Please note that this makes it impossible to have "C"
or "POSIX" as aliases. */
- loc_name = (char *) _nl_expand_alias (*name);
+ loc_name = _nl_expand_alias (*name);
if (loc_name == NULL)
/* It is no alias. */
- loc_name = (char *) *name;
+ loc_name = *name;
/* Make a writable copy of the locale name. */
- loc_name = strdupa (loc_name);
+ loc_name_copy = strdupa (loc_name);
/* LOCALE can consist of up to four recognized parts for the XPG syntax:
@@ -197,7 +197,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
(3) territory
(4) modifier
*/
- mask = _nl_explode_name (loc_name, &language, &modifier, &territory,
+ mask = _nl_explode_name (loc_name_copy, &language, &modifier, &territory,
&codeset, &normalized_codeset);
if (mask == -1)
/* Memory allocate problem. */
---
Cheers,
Carlos.