[texdoc-commits] [SCM] texdoc updated: r10 - in trunk: script tools
karl at gnu.org.ua
karl at gnu.org.ua
Wed May 17 20:05:09 CEST 2017
Author: karl
Date: 2017-05-17 21:05:09 +0300 (Wed, 17 May 2017)
New Revision: 10
Added:
trunk/tools/localetest.tlu
trunk/tools/localetest.txt
Modified:
trunk/script/view.tlu
trunk/tools/Makefile
Log:
reset LC_CTYPE to user value before running the viewer, if we can
Modified: trunk/script/view.tlu
===================================================================
--- trunk/script/view.tlu 2017-05-11 17:42:06 UTC (rev 9)
+++ trunk/script/view.tlu 2017-05-17 18:05:09 UTC (rev 10)
@@ -81,6 +81,7 @@
else
view_command = view_command..' '..viewer_replacement
end
+
-- try to catch problems with missing DISPLAY on Unix
if os.type == 'unix' and not (os.name == 'macosx')
and os.getenv('DISPLAY') == nil then
@@ -90,13 +91,44 @@
"Try --list to list results instead of displaying them.")
end
err_print('info', 'View command: '..view_command)
+
+ -- See long comment below this function for the LC_CTYPE story.
+ -- We only want to reset the environment if we have the value
+ -- to reset it to. In older versions of luatex, status.lc_* will be nil.
+ local env_lc_ctype = status.lc_ctype
+ local luatex_lc_ctype = os.setlocale(nil, 'ctype')
+ if (env_lc_ctype) then
+ err_print('info', "Setting environment LC_CTYPE to: "..env_lc_ctype)
+ os.setenv("LC_CTYPE", env_lc_ctype)
+ end
+
+ -- the big casino: run the external command.
if not os.execute(view_command) then
- err_print('error', "Failed to execute '"..view_command.."'")
+ err_print('error', "Failed to execute: "..view_command)
return false
end
+
+ -- reset back to "C" (should always be C and always happen, but in case...)
+ if (luatex_lc_ctype) then
+ os.setenv("LC_CTYPE", luatex_lc_ctype)
+ end
+
return true
end
+-- Explanation of locale madness:
+-- LuaTeX resets LC_CTYPE, LC_COLLATE, LC_NUMERIC to "C". That is good for
+-- inside luatex, but when we run an external program, if the user's
+-- environment is something else, we want to switch back to it. As of
+-- TL 2017 LuaTeX, we can inspect the user's locale with status.lc_ctype, etc.
+--
+-- For texdoc purposes, what matters is LC_CTYPE (so we don't bother with
+-- the others). For example, with the less pager, when LC_CTYPE=C,
+-- non-ASCII bytes are displayed as "<xx>", where xx is the two hex
+-- digits for the byte.
+--
+-- See <texdoc-dev-source>/tools/Makefile for a standalone test case.
+
----------------------------- display results -----------------------------
-- print a list of docfile objects (see search.tlu) as a menu
Modified: trunk/tools/Makefile
===================================================================
--- trunk/tools/Makefile 2017-05-11 17:42:06 UTC (rev 9)
+++ trunk/tools/Makefile 2017-05-17 18:05:09 UTC (rev 10)
@@ -2,6 +2,47 @@
# Public domain.
tlbin = /usr/local/texlive/pretest/bin/x86_64-linux
+texlua = texlua
+texlua = $(tlbin)/texlua
-../script/Data.tlpdb.lua: gen-datafiles TdTools.pm
+# a moderately unusual locale to test with.
+localetest = de_LU.UTF-8
+#
+# one-line standalone test file with UTF-8 characters.
+localetest-standalone:
+# LC_ALL overrides all specific settings:
+# env LC_ALL=$(localetest) $(texlua) localetest.tlu
+# change just the one relevant setting:
+ unset LC_ALL; env LC_CTYPE=$(localetest) $(texlua) localetest.tlu
+#
+# locale test of texdoc itself. Explanation of envvars:
+# LC_ALL - must unset (or also set) for LC_CTYPE to be effective.
+# LC_CTYPE - the test value to enable UTF-8.
+# LESS - -f means open "binary" files, -d suppresses useless warning
+# about too-dumb terminals, -F exits immediately if file fits.
+# LINES - make a long "screen" so less won't try to page.
+# PAGER - override whatever might be in the regular environments.
+# TEXMFHOME - use
+# PATH - must get TL2017-or-newer texlua
+#
+# Then invoking texdoc.tlu from inside TEXMFHOME makes it find the
+# subfiles in our development directory. -v says to report informational
+# messages too, and the doc for zxjatype is a README text file in UTF-8.
+#
+# The output should be true binary characters, not including ASCII
+# "<xx>" representations of binary bytes. If you use an older luatex, or
+# an older texdoc, you should see those ASCII <xx>'s.
+#
+TEXMFHOME = `pwd`/texmf
+doc_for_pkg = zxjatype
+#
+localetest-script:
+ unset LC_ALL; env LC_CTYPE=$(localetest) \
+ LESS="-f -d -F" LINES=9999 PAGER=less \
+ TEXMFHOME=$(TEXMFHOME) PATH=$(tlbin):$(PATH) \
+ $(TEXMFHOME)/scripts/texdoc/texdoc.tlu -v $(doc_for_pkg)
+
+# rebuild the predigested database of doc files from tlpdb.
+#
+../script/Data.tlpdb.lua data: gen-datafiles TdTools.pm
./gen-datafiles --tl=$(tlbin)
Index: trunk/tools/localetest.tlu
===================================================================
--- trunk/tools/localetest.tlu 2017-05-11 17:42:06 UTC (rev 9)
+++ trunk/tools/localetest.tlu 2017-05-17 18:05:09 UTC (rev 10)
Property changes on: trunk/tools/localetest.tlu
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: trunk/tools/localetest.txt
===================================================================
--- trunk/tools/localetest.txt 2017-05-11 17:42:06 UTC (rev 9)
+++ trunk/tools/localetest.txt 2017-05-17 18:05:09 UTC (rev 10)
Property changes on: trunk/tools/localetest.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
More information about the texdoc-commits
mailing list