This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: search locale archive again after alias expansion


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]