summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-13 17:59:59 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-13 17:59:59 +0000
commit4bba17d6b5618bc0d91699a5c2a0bc4bc21de2b5 (patch)
treeed643648b0361aedb61f7964f946a8061ddafa8b
parentb7e66a6b6cb1baa32472a833104570649a9a98dc (diff)
new alias from texdoc.cnf feature
git-svn-id: svn://tug.org/texlive/trunk@9521 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf/scripts/texlive/texdoc.tlu45
1 files changed, 26 insertions, 19 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu
index c4619dad416..bbb18bc15ce 100755
--- a/Master/texmf/scripts/texlive/texdoc.tlu
+++ b/Master/texmf/scripts/texlive/texdoc.tlu
@@ -72,18 +72,6 @@ while table.maxn(arg) > 0 and string.match(arg[1],'^%-') do
end
end
---[[ aliases ]]
-function alias_subs (name)
- if name == "eg-live" or name == "eg-texlive" then
- return "eg-texlive-en"
- else
- return name
- end
-end
-for i, name in ipairs(arg) do
- arg[i] = alias_subs(name)
-end
-
--[[ function definitions ]]
function list_iter (t)
local i = 0
@@ -202,8 +190,10 @@ end --function recurse_tree
-- [[ set values from config files or defaults ]]
+-- also set aliases from config files while we're at it
-config = {} -- everything is stored in this table
+config = {} -- everything is stored in this table ...
+alias = {} -- ... except aliases
-- newer values don't override older ones
function set_config_element (key, value)
if config[key] == nil then
@@ -216,6 +206,12 @@ function set_config_list (conf)
set_config_element (key, value)
end
end
+-- set an alias
+function set_alias (key, value)
+ if alias[key] == nil then
+ alias[key] = value
+ end
+end
-- first, we shall make use of some environment variables
set_config_list {
@@ -240,18 +236,24 @@ function read_config_file(configfile)
if line == nil then break end -- EOF
line=string.gsub(line, '%s*#.*$', '') -- comments begin with #.
line=string.gsub(line, '%s*$', '') -- remove trailing spaces.
- if (string.match(line, '[%a_]+%s*=%s*.+')) then
- key, val=string.match(line, '([%a_]+)%s*=%s*(.+)')
+ line=string.gsub(line, '^%s*', '') -- remove leading spaces.
+ key, val=string.match(line, '^([%a_]+)%s*=%s*(.+)')
+ if key and val then
set_config_element(key, val)
else
- if (not string.match (line, '^%s*$')) then
- debug (configfile..': Syntax error: '..line)
+ key, val = string.match(line, '^alias%s+([%a_]+)%s*=%s*(.+)')
+ if key and val then
+ set_alias(key, val)
+ else
+ if (not string.match (line, '^%s*$')) then
+ print_debug (configfile..': Syntax error: '..line)
+ end
end
end
end
cnf:close()
else
- debug ('config file "'..configfile..'" not found')
+ print_debug ('config file "'..configfile..'" not found')
end
end
@@ -274,10 +276,11 @@ function setup_config ()
}
--
for i, configfile in ipairs(configfiles) do -- process all config files
- debug ('processing "'..configfile..'"')
+ print_debug ('processing "'..configfile..'"')
read_config_file(configfile)
end
end
+setup_config ()
-- for default viewer on general Unix, we use a list
-- and check in the path in order to find a suitable program
@@ -461,6 +464,10 @@ end
-- [[ the main loop ]]
for docname in list_iter (arg) do
+ if alias[docname] then
+ print ("texdoc info: "..docname.." aliased to "..alias[docname])
+ docname = alias[docname]
+ end
local docfound = false
if string.match(mode,'search') then
docfound = true