commit:     3f84c06c7918b93e9acab1c7fb25be3c03f103ca
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Oct 27 23:23:50 2025 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Mon Oct 27 23:23:50 2025 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=3f84c06c

Introduce the print_warning() helper subroutine

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

 locale-gen | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/locale-gen b/locale-gen
index 43bc931..3265b0d 100644
--- a/locale-gen
+++ b/locale-gen
@@ -351,21 +351,16 @@ sub parse_config ($fh, $path, $supported_by) {
                my @warnings;
                if ($locale =~ s/\.UTF\K8(?=@|\z)/-8/) {
                        push @warnings,
-                               sprintf "WARNING! Codeset specified as UTF8 
(should be UTF-8) at %s[%d]: %s",
+                               sprintf "Codeset specified as UTF8 (should be 
UTF-8) at %s[%d]: %s",
                                        $path, $., render_printable($line);
                }
                if ($charmap =~ s/^UTF\K8\z/-8/) {
                        push @warnings,
-                               sprintf "WARNING! Charmap specified as UTF8 
(should be UTF-8) at %s[%d]: %s",
+                               sprintf "Charmap specified as UTF8 (should be 
UTF-8) at %s[%d]: %s",
                                        $path, $., render_printable($line);
                }
                for my $warning (@warnings) {
-                       if (-t 2) {
-                               *STDOUT->flush;
-                               warn colored($warning, 'bold yellow') . "\n";
-                       } else {
-                               warn "$warning\n";
-                       }
+                       print_warning("WARNING! $warning\n");
                }
 
                # Validate both locale and character map before accepting.
@@ -690,6 +685,15 @@ sub can_run ($bin) {
        return any(sub { -f "$_/$bin" && -x _ }, path());
 }
 
+sub print_warning ($warning) {
+       if (-t 2) {
+               *STDOUT->flush;
+               print STDERR colored($warning, 'bold yellow');
+       } else {
+               print STDERR $warning;
+       }
+}
+
 END {
        if ($$ == $PID) {
                if (@TEMPFILES) {

Reply via email to