commit:     069dacc0fef91e46cda92838987fd241a835f7ba
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jan 12 02:49:14 2026 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Mon Jan 12 03:02:02 2026 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=069dacc0

Simplify the behaviour of select_config_files()

Presently, locale-gen(8) incorporates the following behaviour:

   If the config file is missing, empty, or consists only of comments,
   locale-gen shall act in one of two ways, depending on whether the -c
   option or LOCALEGEN_CONFIG environment variable was specified. If
   neither was specified, locale-gen shall act as if the -A option had
   been specified. Otherwise, locale-gen shall abort.

I now consider it a mistake to have designed the utility in such a way
that the reaction to the config file is partly based on its provenance.

Simplify matters by always falling back to the SUPPORTED file. The new
behaviour is documented as thus:

   If the file contains no locales or is missing, locale-gen shall act
   as if the -A option had been specified.

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

 locale-gen   | 9 ++++-----
 locale-gen.8 | 4 +---
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/locale-gen b/locale-gen
index 91caa81..17e67d1 100644
--- a/locale-gen
+++ b/locale-gen
@@ -214,19 +214,18 @@ sub parse_opts ($known_prefix, @args) {
 }
 
 sub select_config_files ($prefix, %opt) {
-       my $path1 = catfile($prefix, '/etc', 'locale.gen');
-       my $path2 = catfile($prefix, '/usr/share/i18n', 'SUPPORTED');
+       my $fallback_path = catfile($prefix, '/usr/share/i18n', 'SUPPORTED');
        return do {
                if (exists $opt{'config'}) {
                        $opt{'config'};
                } elsif ($opt{'all'}) {
-                       $path2;
+                       ();
                } elsif (exists $ENV{'LOCALEGEN_CONFIG'}) {
                        $ENV{'LOCALEGEN_CONFIG'};
                } else {
-                       $path1, $path2;
+                       catfile($prefix, '/etc', 'locale.gen');
                }
-       };
+       }, $fallback_path;
 }
 
 sub show_usage (@options) {

diff --git a/locale-gen.8 b/locale-gen.8
index bf3cdab..4371d92 100644
--- a/locale-gen.8
+++ b/locale-gen.8
@@ -23,15 +23,13 @@ locale\-gen - safely compile and install a glibc locale 
archive
 The locale\-gen utility provides a means by which a system administrator may 
conveniently manage the set of locales that are made available to the GNU C 
Library. It accomplishes this by acting as a user-friendly frontend for the 
\fBlocaledef\fR(1) utility, which is used to compile locales and integrate them 
into a central archive.
 .P
 By default, locale\-gen generates an archive containing a full complement of 
supported locales, numbering 500 or more. However, it is typical for an 
administrator to require only a few of them. In that case, the \fIconfig\fR 
file may be populated with a list of the required locales. Consequently, 
locale\-gen shall compile only those, saving both time and space in the longer 
term.
-.P
-If the \fIconfig\fR file is missing, empty, or consists only of comments, 
locale\-gen shall act in one of two ways, depending on whether the \fB\-c\fR 
option or LOCALEGEN\_CONFIG environment variable was specified. If neither was 
specified, locale\-gen shall act as if the \fB\-A\fR option had been specified. 
Otherwise, locale\-gen shall abort.
 .SH "OPTIONS"
 .TP
 \fB\-A\fR, \fB\-\-all\fR
 Compile all locales that are officially supported by glibc. Cannot be combined 
with the \fB-c\fR option.
 .TP
 \fB\-c\fR, \fB\-\-config\fR \fIconfig\fR
-Read the given \fIconfig\fR file (defaults to \fIprefix\fR/etc/locale.gen). If 
specified as a \%<hyphen-minus>, the configuration shall be read from standard 
input.
+Read the given \fIconfig\fR file (defaults to \fIprefix\fR/etc/locale.gen). If 
specified as a \%<hyphen-minus>, the configuration shall be read from standard 
input. If the file contains no locales or is missing, locale\-gen shall act as 
if the \fB-A\fR option had been specified.
 .TP
 \fB\-h\fR, \fB\-\-help\fR
 Write out a synopsis and summary of the supported options then exit.

Reply via email to