summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texdoc/search.tlu
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2011-06-06 04:24:43 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2011-06-06 04:24:43 +0000
commitccd2c7338d8bcbacffe531d9c43493f7f8035517 (patch)
tree2b28f03c11c0f7c7fb5f8ac70de88f992199b019 /Master/texmf/scripts/texdoc/search.tlu
parente1ed0075e33f4d74cc66bf8e13f2e2ccd3d8fdbf (diff)
texdoc 0.81
git-svn-id: svn://tug.org/texlive/trunk@22812 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/scripts/texdoc/search.tlu')
-rw-r--r--Master/texmf/scripts/texdoc/search.tlu47
1 files changed, 17 insertions, 30 deletions
diff --git a/Master/texmf/scripts/texdoc/search.tlu b/Master/texmf/scripts/texdoc/search.tlu
index 11203fd97c5..1499c65414a 100644
--- a/Master/texmf/scripts/texdoc/search.tlu
+++ b/Master/texmf/scripts/texdoc/search.tlu
@@ -1,19 +1,6 @@
--- File searching 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.
---]]
-
--- Load a private environment for this submodule (see texdoc.tlu).
-local L = {}
-load_env(L, {
- 'os', 'lfs', 'kpse', 'io', 'setmetatable', 'print',
- 'dofile', 'loadfile', 'setfenv', 'rawget', 'rawset',
- 'parse_zip', 'path_parent',
- 'get_patterns', 'sort_doclist', 'docfile_quality', 'ext_pos',
- 'config',
-})
+-- search.tlu: file searching functions for texdoc.
+--
+-- Manuel Pégourié-Gonnard, GPLv3, see texdoclib.tlu for details
-- Warning: every single function here assumes init_databases() has been called.
@@ -362,13 +349,21 @@ function check_ext(file)
return false
end
+-- say if a file (with its path) matches a pattern
+function matches(pattern, file)
+ if pattern.original then
+ return string.find(file:lower(), pattern.name:lower(), 1, true)
+ else
+ return is_exact(file, pattern.name)
+ end
+end
+
-- return a docfile object if file "matches", nil ortherwise
function process_file(patlist, file, pathfile, code)
local docfile
local pattern
for _, pattern in ipairs(patlist) do
- if string.find(string.lower(pathfile), string.lower(pattern.name),
- 1, config.mode ~= 'regex') then
+ if matches(pattern, pathfile) then
local info = {
name = pathfile,
tree = code,
@@ -568,12 +563,6 @@ function get_tlpinfo_from_cache(filename)
s_meta, tlp_from_runfile, tlp_doclist = dofile(filename)
end
--- get pre-hashed meta from a file
-function get_meta_hack()
- local f = assert(kpse.find_file(C.data_meta_name, 'texmfscripts'))
- s_meta = dofile(f)
-end
-
-- get pre-hashed tlpdb info from a pseudo-cache file
function get_tlpinfo_from_dist()
local f = assert(kpse.find_file(C.data_tlpdb_name, 'texmfscripts'))
@@ -633,7 +622,6 @@ end
-- separate sty patterns from the rest
function normal_vs_sty(list)
- if config.mode == 'regex' then return list, {} end
local normal, sty = {}, {}
for _, p in ipairs(list) do
if string.match(string.lower(p.name), '%.([^/.]*)$') == 'sty' then
@@ -645,8 +633,7 @@ function normal_vs_sty(list)
return normal, sty
end
--- finally export a few symbols
-export_symbols(L, {
- 'init_databases',
- 'get_doclist',
-})
+return {
+ init_databases = init_databases,
+ get_doclist = get_doclist,
+}