diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-31 15:58:27 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-31 15:58:27 +0000 |
commit | b31f7b14b6271276bbde00d2652433746025be5f (patch) | |
tree | a6517a54cabf69362df27cee11511842b28fd28d | |
parent | 53b8372147b0f2a4ca0a951f673fc0ddc87185f9 (diff) |
Now set_config_element() remembers the "inverse" of the list and its max while
setting it. Using this in file_order(). Rm ext_orderi() accordinfly. Also
removing the old useless function print_ordered_byext().
git-svn-id: svn://tug.org/texlive/trunk@9941 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/texdoc.tlu | 47 |
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) |