summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texdoc/functions.tlu
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2009-11-16 18:04:31 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2009-11-16 18:04:31 +0000
commit97a64664af52df12bf2780903c3357ad8d29a94a (patch)
tree862a7ea3de828c5a8fbc71c2f1f1e9f7ec2c9738 /Master/texmf/scripts/texdoc/functions.tlu
parentf50077230cf2978d84fe11faf2529484c2067d0b (diff)
Texdoc 0.50.
git-svn-id: svn://tug.org/texlive/trunk@16031 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/scripts/texdoc/functions.tlu')
-rw-r--r--Master/texmf/scripts/texdoc/functions.tlu58
1 files changed, 58 insertions, 0 deletions
diff --git a/Master/texmf/scripts/texdoc/functions.tlu b/Master/texmf/scripts/texdoc/functions.tlu
new file mode 100644
index 00000000000..faee493f156
--- /dev/null
+++ b/Master/texmf/scripts/texdoc/functions.tlu
@@ -0,0 +1,58 @@
+-- General use functions for texdoc
+--[[
+Copyright 2008, 2009 Manuel Pégourié-Gonnard
+Distributed under the terms of the GNU GPL version 3 or later.
+See texdoc.tlu for details.
+--]]
+
+local L = {}
+load_env(L, {
+ 'export_symbols',
+ 'string', 'io', 'os',
+ 'ipairs',
+ 'C',
+ 'config',
+})
+
+-- change '/' to '\' on windows
+if os.type == "windows" then
+ function win32_hook (path)
+ local res = string.gsub (path, '/', '\\')
+ return res -- get rid of gsub's 2nd return value
+ end
+else
+ function win32_hook (path)
+ return path
+ end
+end
+
+-- generic error display function (see the error_priority constant)
+function err_print (msg, lvl)
+ -- be careful: maybe config.verbosity_level is not set yet
+ local verbosity_level = config.verbosity_level or 2
+ if C.err_priority[lvl] <= verbosity_level then
+ io.stderr:write ("texdoc "..lvl..": "..msg.."\n")
+ end
+end
+
+-- if zip is support and file is base..'.'..zip with zip in zipext_list,
+-- return base, zip -- otherwise, returns file, nil
+function parse_zip(file)
+ if C.support_zipped then
+ local zip
+ for _, zip in ipairs(config.zipext_list) do
+ local l = #zip + 1
+ if string.sub(file, -l, -1) == '.'..zip then
+ return string.sub(file, 1, -l - 1), zip
+ end
+ end
+ end
+ return file, nil
+end
+
+-- finally export a few symbols
+export_symbols(L, {
+ 'err_print',
+ 'win32_hook',
+ 'parse_zip',
+})