summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/texdoc.tlu47
1 files changed, 13 insertions, 34 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu
index ab3f6d73b70..cc9c791b2fc 100755
--- a/Master/texmf/scripts/texlive/texdoc.tlu
+++ b/Master/texmf/scripts/texlive/texdoc.tlu
@@ -262,13 +262,17 @@ end
function set_config_element (key, value, file, line)
if config[key] == nil then
if string.match(key, '_list$') then
- -- this is actually a coma-separeted list of values
+ -- this is actually a coma-separated list of values
local values = string.explode(value, ',')
+ local inverse = {}
for i, j in ipairs(values) do
values[i] = string.gsub(j, '%s*$', '')
values[i] = string.gsub(j, '^%s*', '')
+ inverse[j] = i
end
config[key] = values
+ config[key..'_inv'] = inverse
+ config[key..'_max'] = #values
elseif string.find (key, '_switch$') then
if value == 'true' then
config[key] = true
@@ -601,52 +605,27 @@ function try_viewing (view_command, viewer_replacement)
return view_result
end
--- display the results of a search and let user choose
-function print_ordered_byext (files_list)
- for _, ext in ipairs (config.ext_list) do
- if ext == '' then
- ext_pattern = '/[^.]*$'
- elseif ext == '*' then
- ext_pattern = ''
- else
- ext_pattern = '%.'..ext..'$'
- end
- for file in list(files_list) do
- if string.match (file, ext_pattern) then print (file) end
- end
- end
-end
-
-- compare two files with the following rule:
-- 1. extensions are ordered as in ext_list first,
-- 2. then filenames lexicograhpicaly.
function file_order (a, b)
+ print ("compare", a, b)
local ext_a = string.match (a, '^.*%.(.*)$')
local ext_b = string.match (b, '^.*%.(.*)$')
- if ext_pos(ext_a) < ext_pos(ext_b) then
+ ext_pos_a = config.ext_list_inv[ext_a] or (config.ext_list_max+1)
+ ext_pos_b = config.ext_list_inv[ext_b] or (config.ext_list_max+1)
+ if ext_pos_a < ext_pos_b then
+ print "a < b"
return true
- elseif ext_pos(ext_a) > ext_pos(ext_b) then
+ elseif ext_pos_a > ext_pos_b then
+ print "a > b"
return false
else
+ print "a = b"
return (a < b)
end
end
--- return the position of ext in ext_list, and greater value if not in ext_list
--- magic inside: compute ext_reverse only once
-function ext_pos (ext)
- local ext_rev = {}
- local max
- for i, ext in ipairs (config.ext_list) do
- ext_rev[ext] = i
- max = i
- end
- ext_pos = function (e)
- return ext_rev[e] or (max + 1)
- end
- return ext_pos (ext)
-end
-
-- display a table, sorted, numbered with given offset (0 by default),
-- with real path
function display_table (t, offset)