summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-15 16:28:34 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-15 16:28:34 +0000
commit20e1c67c2bad0ca817460828fd1eca08067132fc (patch)
tree14e21612c95da6f593e800d88b07b3a667496998 /Master
parent28541f3d36017782f2d5468299a1e3801751edb8 (diff)
separate code for zipped documentation and disable it by default. Easy to enable (see comments) but will most likely not work everywhere.
git-svn-id: svn://tug.org/texlive/trunk@9573 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/texdoc.tlu80
1 files changed, 42 insertions, 38 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu
index 6255e7abae2..5b88a678734 100755
--- a/Master/texmf/scripts/texlive/texdoc.tlu
+++ b/Master/texmf/scripts/texlive/texdoc.tlu
@@ -32,6 +32,17 @@ Sorry, I'm not smart enough to find documentation for PKGNAME. Please see
http://tug.org/pkginfo/PKGNAME for information about the package.]]
place_holder = '%%s' -- used for viewer commands
+--[[ zip/gz support ]]
+-- optionally, texdoc can support compressed documentation, but this is
+-- system-dependant (commands for unzipping, temporary files, etc).
+-- Since TeX Live doesn't ship compressed doc, downstream distributors who
+-- want to ship zipped should change support_zipped to true *and* make sure
+-- everything works for them (look for support_zipped in the code).
+-- If you use this feature, please let us know: if nobody uses it,
+-- we'll drop it at some point.
+support_zipped = false
+
+
-- [[ for our eyes only ]]
opt_debug = false
-- print debugging messages to stderr
@@ -322,8 +333,6 @@ if (os.type == "windows") then
-- probably Windows (or OS/2)
-- which commands should we use for unzipping?
set_config_list {
- unzip_gz = "gzip -d -c ",
- unzip_bz2 = "bzip2 -d -c ",
viewer_dvi = '(start /wait %s) &',
viewer_html = '(start /wait %s) &',
viewer_pdf = '(start /wait %s) &',
@@ -332,10 +341,6 @@ if (os.type == "windows") then
viewer_tex = '(start /wait %s) &'
}
else -- since we don't support msdos, if os.type is not windows, it's unix
- set_config_list {
- unzip_gz = "gzip -d -c ",
- unzip_bz2 = "bzip2 -d -c ",
- }
if (os.name == 'macosx') then
set_config_list {
viewer_dvi = '(open %s)',
@@ -394,10 +399,13 @@ else -- since we don't support msdos, if os.type is not windows, it's unix
end
-- now a particular case for config.ext_list
-set_config_element('ext_list',
+if support_zipped then
+ set_config_element('ext_list',
'.pdf, .pdf.gz, .pdf.bz2, .dvi, .dvi.gz, .dvi.bz2,'..
- '.ps, .ps.gz, .ps.bz2, .txt, .txt.gz, .txt.bz2, .html'
-)
+ '.ps, .ps.gz, .ps.bz2, .txt, .txt.gz, .txt.bz2, .html')
+else
+ set_config_element('ext_list', '.pdf, .html, .txt, .dvi, .ps')
+end
-- 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
@@ -408,28 +416,28 @@ end
-- [[ functions for viewing ]]
--- uncompress if needed
-function unzip_if_needed (ext)
- zipext = string.match(ext,'%..*%.(.*)')
- if zipext then
- unzip_command = config['unzip_'..zipext]
- viewext = string.match(ext,'%.(.*)%..*$')
- basename_pattern = '.*/(.*%.' .. viewext .. ')'
- basename = string.match(filename,basename_pattern)
- -- uncompress only once per file, in case it is given
- -- more than once (dvi besides ps or so)
- -- TODO: to be done
- tmpdir = os.tmpdir("/tmp/texdoc.XXXXXX")
- unzip_commandline = unzip_command .. filename .. " > "
- .. tmpdir .. "/" .. basename
- if os.execute(unzip_commandline) then
- os.execute ("ls "..tmpdir)
- print ("unzipped to tmpdir")
- filename = tmpdir .. "/" .. basename
- else
- print("Error executing \n" .. unzip_commandline)
+-- prepare for viewing set viewer_replacement and viwer_ext
+-- may uncompress if support_zipped is set (giving the complete filename on the
+-- command line is unsupported for compressed files by the way)
+function prepare_viewing (ext)
+ if support_zipped then
+ zipext = string.match(ext,'%..*%.(.*)')
+ if zipext then
+ unzip_command = config['unzip_'..zipext]
+ viewext = string.match(ext,'%.(.*)%..*$')
+ basename_pattern = '.*/(.*%.' .. viewext .. ')'
+ basename = string.match(filename,basename_pattern)
+ tmpdir = os.tmpdir("/tmp/texdoc.XXXXXX")
+ unzip_commandline = unzip_command .. filename .. " > "
+ .. tmpdir .. "/" .. basename
+ if os.execute(unzip_commandline) then
+ filename = tmpdir .. "/" .. basename
+ else
+ print("Error executing \n" .. unzip_commandline)
+ end
+ viewer_replacement = filename .. ';' .. config.rm_file
+ .. filename .. ';' .. config.rm_dir .. tmpdir
end
- -- shall_cleanup = true
else
if ext == '' then
-- fallback if complete filename has been specified
@@ -439,6 +447,7 @@ function unzip_if_needed (ext)
ext = 'txt'
end
end
+ viewer_replacement = filename
viewext = string.match(ext,'%.(.*)$')
if not viewext or not config['viewer_'..viewext] then
-- complete filename specified, unknown extension, use "txt"
@@ -457,9 +466,9 @@ function try_viewing ()
view_command = config['viewer_'..viewext]
if string.match (view_command, place_holder) then
view_command = string.gsub(
- view_command, place_holder, '"'..filename..'"')
+ view_command, place_holder, '"'..viewer_replacement..'"')
else
- view_command = view_command..' "'..filename..'"'
+ view_command = view_command..' "'..viewer_replacement..'"'
end
if verbose then
print(view_command)
@@ -469,10 +478,6 @@ function try_viewing ()
print("Error executing \n" .. view_command)
end
end
- if shall_cleanup then
- os.remove (filename)
- os.remove (tmpdir)
- end
return view_result
end
@@ -495,8 +500,7 @@ for docname in list_iter (arg) do
if string.match (mode, 'list') then
print(filename)
else -- mode is view, is unzipping needed?
- local tmpdir, filename, viewext, shall_cleanup
- unzip_if_needed(ext)
+ prepare_viewing(ext)
local ok = try_viewing()
if ok then break end
end -- list or view