texinfo-commits
[Top][All Lists]
Advanced

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

[6955] get name of UTF-8 locale from locale -a


From: Gavin D. Smith
Subject: [6955] get name of UTF-8 locale from locale -a
Date: Sat, 23 Jan 2016 11:28:28 +0000

Revision: 6955
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6955
Author:   gavin
Date:     2016-01-23 11:28:24 +0000 (Sat, 23 Jan 2016)
Log Message:
-----------
get name of UTF-8 locale from locale -a

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Convert/Paragraph.pm
    trunk/tp/Texinfo/Convert/XSParagraph/xspara.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-01-23 10:50:52 UTC (rev 6954)
+++ trunk/ChangeLog     2016-01-23 11:28:24 UTC (rev 6955)
@@ -1,5 +1,16 @@
 2016-01-23  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/Convert/Paragraph.pm: Add a check for a UTF-8 
+       locale in output of "locale -a".  Change 'stand-alone' to 
+       'standalone' in a string.  Remove some commented-out code.
+       * tp/Texinfo/Convert/XSParagraph/xspara.c (xspara_init): If we 
+       fail to set a UTF-8 locale by other means, look at the output of 
+       "locale -a" and use the first line of output with "UTF-8" in it 
+       as the name of the locale to use.  Failure when no UTF-8 locale 
+       could be set reported by Kiyoshi Kanazawa.
+
+2016-01-23  Gavin Smith  <address@hidden>
+
        * NEWS: Move note about @copying next to the news for the 
        release it was added in (Texinfo 4.2, April 2002).
 

Modified: trunk/tp/Texinfo/Convert/Paragraph.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Paragraph.pm       2016-01-23 10:50:52 UTC (rev 
6954)
+++ trunk/tp/Texinfo/Convert/Paragraph.pm       2016-01-23 11:28:24 UTC (rev 
6955)
@@ -116,8 +116,20 @@
   goto FALLBACK;
 }
 
+# Check for a UTF-8 locale.  Skip the check if the 'locale' command doesn't
+# work.
+my $a = `locale -a 2>/dev/null`;
+if ($a and $a !~ /UTF-8/ and $a !~ /utf8/) {
+  _fatal "couldn't find a UTF-8 locale";
+  goto FALLBACK;
+}
+if (!$a) {
+  _debug "couldn't run 'locale -a': skipping check for a UTF-8 locale";
+}
+
+
 my ($libtool_dir, $libtool_archive);
-if ($TEXINFO_XS ne 'stand-alone') {
+if ($TEXINFO_XS ne 'standalone') {
   ($libtool_dir, $libtool_archive) = _find_file("XSParagraph.la");
   if (!$libtool_archive) {
     if ($TEXINFO_XS eq 'libtool') {
@@ -178,14 +190,6 @@
 
 LOAD:
 
-#print STDERR "loadable object is at $dlpath\n";
-
-# Following steps under "bootstrap" in "man DynaLoader".
-#bootstrap XSParagraph $VERSION;
-
-# TODO: Execute blib/arch/auto/XSParagraph/XSParagraph.bs ?
-# That file is empty.
-
 #my $flags = dl_load_flags $module; # This is 0 in DynaLoader
 my $flags = 0;
 my $libref = DynaLoader::dl_load_file($dlpath, $flags);

Modified: trunk/tp/Texinfo/Convert/XSParagraph/xspara.c
===================================================================
--- trunk/tp/Texinfo/Convert/XSParagraph/xspara.c       2016-01-23 10:50:52 UTC 
(rev 6954)
+++ trunk/tp/Texinfo/Convert/XSParagraph/xspara.c       2016-01-23 11:28:24 UTC 
(rev 6955)
@@ -241,6 +241,37 @@
   memcpy (dot, ".utf8", 6);
   if (setlocale (LC_CTYPE, utf8_locale))
     goto success;
+
+  /* Otherwise, look for any UTF-8 locale in the output of "locale -a". */
+  {
+  FILE *p;
+  char *line = 0;
+  size_t n = 0;
+  ssize_t ret;
+  p = popen ("locale -a", "r");
+  if (!p)
+    goto failure;
+  while (1)
+    {
+      ret = getline (&line, &n, p);
+      if (ret == (ssize_t) -1)
+        {
+          free (line);
+          pclose (p);
+          goto failure;
+        }
+      if (strstr (line, "UTF-8") || strstr (line, "utf8"))
+        {
+          line[ret - 1] = '\0';   /* Remove trailing newline. */
+          if (setlocale (LC_CTYPE, line))
+            {
+              free (line);
+              pclose (p);
+              goto success;
+            }
+        }
+    }
+  }
       
   if (1)
     {




reply via email to

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