commit:     882fce549fd5ea663b0bf550f9da4433332353c5
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Aug 10 21:08:11 2025 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Sun Aug 10 21:17:20 2025 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=882fce54

Allow for locale declarations to have trailing comments

The two fields that form a locale definition may now be followed by a
comment, provided that its leading <number-sign> character is enclosed
by <blank> characters.

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

 locale-gen   |  3 +++
 locale.gen.5 | 12 ++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/locale-gen b/locale-gen
index 948ee59..3a1dadf 100755
--- a/locale-gen
+++ b/locale-gen
@@ -329,6 +329,9 @@ sub parse_config ($fh, $path, $locale_by, $charmap_by) {
                # " " and "\t", since the input stream is not being decoded.
                next if $line =~ m/^\h*($|#)/;
 
+               # Permit comments trailing locale declarations.
+               $line =~ s/\h\K#\h.*//;
+
                # Expect for two fields, separated by horizontal whitespace.
                my @fields;
                chomp $line;

diff --git a/locale.gen.5 b/locale.gen.5
index 5a56e60..f5e6edf 100644
--- a/locale.gen.5
+++ b/locale.gen.5
@@ -13,9 +13,12 @@ considered as a \fIlocalename\fR and the second field as a 
\fIcharmap\fR. The
 combinations.
 .P
 Lines that are empty, or which contain only <blank> characters, shall be
-disregarded. Also, lines that begin with zero or more <blank> characters,
-followed by a <number\-sign> character,  shall be considered as comments and
-disregarded.
+disregarded. Lines that begin with zero or more <blank> characters, followed by
+a <number\-sign> character, shall be considered as comments and disregarded.
+Further, the two fields that form a locale definition may be followed by a
+comment, provided that its leading <number\-sign> character is enclosed by
+<blank> characters.
+
 .P
 The definition of a <blank> character is that it is either the <tab> or <space>
 character.
@@ -53,7 +56,8 @@ en_US.UTF\-8  UTF\-8
 zh_CN.UTF\-8  UTF\-8
 de_DE.UTF\-8  UTF\-8
 hi_IN.UTF\-8  UTF\-8
-ja_JP.UTF\-8  UTF\-8
+ja_JP.UTF\-8  UTF\-8 # trailing comments are permitted
+
 .sp
 # This is invalid because the charmap field is missing.
 en_US.UTF\-8

Reply via email to