texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Tue, 6 Jul 2021 08:09:07 -0400 (EDT)

branch: master
commit 13364f2fa5d17934073bd8ed2a7e9be2b4598103
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Jul 6 13:08:47 2021 +0100

    Avoid repeated "locale -a" calls.
    
    * tp/Texinfo/Report.pm (gdt): Only try to call "locale -a" once
    and check its exit status.
---
 ChangeLog            |  7 +++++++
 tp/Texinfo/Report.pm | 16 ++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ec54af3..70f0d93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-07-06  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       Avoid repeated "locale -a" calls.
+
+       * tp/Texinfo/Report.pm (gdt): Only try to call "locale -a" once
+       and check its exit status.
+
 2021-07-05  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Find working locale for gettext
diff --git a/tp/Texinfo/Report.pm b/tp/Texinfo/Report.pm
index bea2200..96793b5 100644
--- a/tp/Texinfo/Report.pm
+++ b/tp/Texinfo/Report.pm
@@ -260,12 +260,16 @@ sub gdt($$;$$)
   if (!$locale) {
     $locale = POSIX::setlocale(LC_ALL, "en_US")
   }
-  if (!$locale) {
-    my @locales = split("\n", `locale -a`);
-    for my $try (@locales) {
-      next if $try eq 'C' or $try eq 'POSIX';
-      $locale = POSIX::setlocale(LC_ALL, $try);
-      last if $locale;
+  our $locale_command;
+  if (!$locale and !$locale_command) {
+    $locale_command = "locale -a";
+    my @locales = split("\n", `$locale_command`);
+    if ($? == 0) {
+      for my $try (@locales) {
+        next if $try eq 'C' or $try eq 'POSIX';
+        $locale = POSIX::setlocale(LC_ALL, $try);
+        last if $locale;
+      }
     }
   }
   $working_locale = $locale;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]