commit:     c9f73b6eef74e869110fc5267c7824a24b75d9c8
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Nov 21 11:41:23 2025 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Fri Nov 21 11:41:36 2025 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=c9f73b6e

Decide the value of $name in parse_config(), not parse_entry()

Nothing is being conveyed to the parse_entry() subroutine that needs to
be parsed in order to determine the value of the $name variable.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 locale-gen | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/locale-gen b/locale-gen
index e715807..3827cf4 100644
--- a/locale-gen
+++ b/locale-gen
@@ -395,7 +395,14 @@ sub parse_config ($fh, $path, $supported_by) {
                # Determine the locale name in both the form that accords with
                # the subdirectories of /usr/share/i18n/locales, and in the
                # canonical form that incorporates the <codeset> part.
-               ($locale, my $canonical, my $name) = parse_entry($locale, 
$charmap, $is_aliasable);
+               ($locale, my $canonical) = parse_entry($locale, $charmap);
+
+               # Where given an input path whose name lacks a codeset part,
+               # localedef(1) will incorporate it into the archive as an alias
+               # of its canonical name. For example, "en_US" may refer to
+               # "en_US.iso88591". It is strongly discouraged to rely on this
+               # behaviour. Still, for now, arrange for such aliases to exist.
+               my $name = $is_aliasable ? $locale : $canonical;
 
                push @locales, [ $locale, $charmap, $canonical, $name ];
        }
@@ -403,7 +410,7 @@ sub parse_config ($fh, $path, $supported_by) {
        return @locales;
 }
 
-sub parse_entry ($locale, $charmap, $is_aliasable) {
+sub parse_entry ($locale, $charmap) {
        my $canonical;
        my $name;
        if (2 == (my @fields = split /@/, $locale, 3)) {
@@ -416,17 +423,8 @@ sub parse_entry ($locale, $charmap, $is_aliasable) {
        } elsif (1 == @fields) {
                # en_US ISO-8859-1 => en_US.ISO-8859-1
                $canonical = "$locale.$charmap";
-
-               # Where given an input path whose name lacks a codeset part,
-               # localedef(1) will incorporate it into the archive as an alias
-               # of its canonical name. For example, "en_US" may refer to
-               # "en_US.iso88591". It is strongly discouraged to rely on this
-               # behaviour. Still, for now, arrange for such aliases to exist.
-               if ($is_aliasable) {
-                       $name = $locale;
-               }
        }
-       return $locale, $canonical, $name // $canonical;
+       return $locale, $canonical;
 }
 
 sub check_archive_dir ($prefix, $locale_dir) {

Reply via email to