summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-15 23:56:31 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-15 23:56:31 +0000
commit5dd5aa0744705fbac6f0093f5092108d8ddaf7bb (patch)
tree373d2c45f5286c36b49002a5e5fc2d298c731cb0 /Master
parent897a617456f1f95d82fdecb22ac6302eb9ad754f (diff)
Reworking the -s option to display only files whose extension is in ext_list.
git-svn-id: svn://tug.org/texlive/trunk@9590 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/texdoc.tlu66
1 files changed, 40 insertions, 26 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu
index d3cf9bbcdad..4055d25d384 100755
--- a/Master/texmf/scripts/texlive/texdoc.tlu
+++ b/Master/texmf/scripts/texlive/texdoc.tlu
@@ -113,9 +113,8 @@ function deluaficate(oldpat)
return newpat
end --deluaficate
-docdirs = {}
-docfiles = {}
function pattern_search (pattern)
+ docdirs, docfiles = {}, {} -- should not be local (used in recurse_tree)
pattern = deluaficate(pattern)
-- populate docdirs and doclines list
for database in get_lsr_files() do
@@ -131,7 +130,9 @@ function pattern_search (pattern)
-- the next file lines are in docdir "this_dir"
is_docline = true
-- save it in the docdirs table
- table.insert(docdirs,this_dir)
+ if string.match(this_dir, pattern) then
+ table.insert(docdirs,this_dir)
+ end
else
is_docline = false
end -- docdir
@@ -140,41 +141,52 @@ function pattern_search (pattern)
-- now we have only file lines left, are they a docline?
elseif is_docline then
local fullpath = this_dir .. line
- -- print(fullpath)
- table.insert(docfiles,fullpath)
+ if string.match(fullpath, pattern) then
+ if lfs.isfile(fullpath) then -- cannot know form ls-R
+ table.insert(docfiles,fullpath)
+ end
+ end
end -- line starting with ./
end -- for line
end -- for database
for no_lsr_dir in list_iter(no_lsr_doctrees) do
- recurse_tree(no_lsr_dir)
+ recurse_tree(no_lsr_dir, pattern)
end
--
- print("Directories that match:")
+ print("\tDirectories that match:")
for dir in list_iter(docdirs) do
- if string.match(dir,pattern) then
- print (dir)
- end
- end -- for dir
- print()
- print("Files that match:")
- for file in list_iter(docfiles) do
- if string.match(file,pattern) then
- print (file)
+ print (dir)
+ end
+ print("\tFiles that match:")
+ for _, ext in ipairs (config.ext_list) do
+ if ext == '' then
+ ext_pattern = '/[^.]*$'
+ elseif ext == '*' then
+ ext_pattern = ''
+ else
+ ext_pattern = '%.'..ext..'$'
end
- end -- for file
+ for file in list_iter(docfiles) do
+ if string.match (file, ext_pattern) then print (file) end
+ end
+ end
end -- function pattern_search()
-function recurse_tree (path)
+function recurse_tree (path, pattern)
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..'/'..file
local attr = lfs.attributes (f)
if attr then -- else stale symlink
if attr.mode == "directory" then
- table.insert(docdirs,f)
- recurse_tree (f)
+ if string.match (f, pattern) then
+ table.insert(docdirs,f)
+ end
+ recurse_tree (f, pattern)
else
- table.insert(docfiles,f)
+ if string.match (f, pattern) then
+ table.insert(docfiles,f)
+ end
end
end
end
@@ -533,11 +545,13 @@ setup_config_from_env ()
setup_config_from_files ()
setup_config_from_defaults ()
--- we want an empty string for ext at the beginning, so that it works
--- to specify the complete filename. Doesn't matter when there's one
--- more empty string, but we can easily avoid two in a row
-if not (config.ext_list[1] == '') then
- table.insert(config.ext_list,1,'')
+-- we want an empty string for ext at the beginning, so that it works to specify
+-- the complete filename (at least in list or view mode). Doesn't matter when
+-- there's one more empty string, but we can easily avoid two in a row
+if (config.mode == 'view' or config.mode == 'list') then
+ if not (config.ext_list[1] == '') then
+ table.insert(config.ext_list,1,'')
+ end
end
-- the main loop over the args