commit:     576f604108368b021237e4607e2624375adf17e5
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Aug 19 13:29:50 2025 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Tue Aug 19 13:33:33 2025 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=576f6041

mkconfig: ensure column(1) considers its input stream as US-ASCII

In the course of executing column(1), ensure that LC_ALL=C is set in its
environment so that the appropriate character type is in effect.

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

 mkconfig | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/mkconfig b/mkconfig
index fa42452..c455a54 100755
--- a/mkconfig
+++ b/mkconfig
@@ -26,10 +26,8 @@ use File::Slurper qw(read_text);
        # Gather the language and territory attributes of the locale templates.
        my $attr_by = map_locale_attributes($prefix);
 
-       # Use column(1) to write out a nicely columnated list. The encoding is
-       # applied as a precaution; should any wide characters unexpectedly slip
-       # through, they shall be backslash-escaped e.g. U+00E5 => "\x{00e5}".
-       open my $pipe, "|-:encoding(US-ASCII)", "column -t -s \037" or exit 127;
+       # Use column(1) to write out a nicely columnated list.
+       my $pipe = open_column("\037");
 
        while (my $line = readline $fh) {
                my ($read_locale, $charmap) = split ' ', $line;
@@ -107,3 +105,16 @@ sub to_ascii ($str) {
        $str =~ s/\p{NonspacingMark}//g;
        return $str;
 }
+
+sub open_column ($sep) {
+       # Ensure that column(1) considers its input stream as US-ASCII.
+       local $ENV{'LC_ALL'} = 'C';
+
+       # The encoding is applied as a precaution; over-wide characters written
+       # to the pipe become Perl escape sequences e.g. U+00E5 => \x{00e5}.
+       if (! open my $pipe, '|-:encoding(US-ASCII)', 'column', '-ts', $sep) {
+               exit 127;
+       } else {
+               return $pipe;
+       }
+}

Reply via email to