diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-15 11:54:52 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-15 11:54:52 +0000 |
commit | b77de40b9f75a5b2e5d784a5b26ccd87f269d2c1 (patch) | |
tree | be590957f39a5c16941c747d6c8cedabfdea6fe1 | |
parent | f610d06fa387388dd7cd849adc4218c2d93019d1 (diff) |
Handle _list config variables as lists. Rename extlist as tex_list. Allow digits and dashes in config keys. Print a warning for syntax errors in config files.
git-svn-id: svn://tug.org/texlive/trunk@9568 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/texdoc.tlu | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu index 1b4431d63d4..ccc8bb38761 100755 --- a/Master/texmf/scripts/texlive/texdoc.tlu +++ b/Master/texmf/scripts/texlive/texdoc.tlu @@ -197,7 +197,16 @@ alias = {} -- ... except aliases -- newer values don't override older ones function set_config_element (key, value) if config[key] == nil then - config[key] = value + if string.match(key, '_list$') then + local list = string.explode(value, ',') + for i, j in ipairs(list) do + list[i] = string.gsub(j, '%s*$', '') + list[i] = string.gsub(j, '^%s*', '') + end + config[key] = list + else + config[key] = value + end end end -- set a whole list @@ -230,23 +239,26 @@ kpse.set_program_name(arg[-1], "texdoc") function read_config_file(configfile) if (lfs.isfile(configfile)) then -- configfile exists local cnf=assert(io.open(configfile, 'r')) + local lineno = 0 while true do local key, val local line=cnf:read('*line') + lineno = lineno + 1 if line == nil then break end -- EOF line=string.gsub(line, '%s*#.*$', '') -- comments begin with #. line=string.gsub(line, '%s*$', '') -- remove trailing spaces. line=string.gsub(line, '^%s*', '') -- remove leading spaces. - key, val=string.match(line, '^([%a_]+)%s*=%s*(.+)') + key, val=string.match(line, '^([%a%d_]+)%s*=%s*(.+)') if key and val then set_config_element(key, val) else - key, val = string.match(line, '^alias%s+([%a_]+)%s*=%s*(.+)') + key, val = string.match(line, '^alias%s+([%a%d_-]+)%s*=%s*(.+)') if key and val then set_alias(key, val) else if (not string.match (line, '^%s*$')) then - print_debug (configfile..': Syntax error: '..line) + print ('texdoc warning: syntax error in '..configfile.. + ' at line '..lineno..'.') end end end @@ -381,17 +393,17 @@ else -- since we don't support msdos, if os.type is not windows, it's unix end end --- now a particular case for config.extlist -set_config_element('extlist', { - '','.pdf', '.pdf.gz', '.pdf.bz2', '.dvi', '.dvi.gz', '.dvi.bz2', - '.ps', '.ps.gz', '.ps.bz2', '.txt', '.txt.gz', '.txt.bz2', '.html' -}) +-- now a particular case for config.ext_list +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' +) -- 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.extlist[1] == '' then - insert(config.extlist,1,'') +if not config.ext_list[1] == '' then + insert(config.ext_list,1,'') end -- [[ functions for viewing ]] @@ -475,7 +487,7 @@ for docname in list_iter (arg) do docfound = true pattern_search(docname) elseif string.match(mode,'view') or string.match(mode,'list') then - for ext in list_iter(config.extlist) do + for ext in list_iter(config.ext_list) do filename = kpse.find_file(docname .. ext, "TeX system documentation") if filename then |