diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-05 23:29:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-05 23:29:43 +0000 |
commit | 10e6cd9ce34c0ec20d007ebe6ce8fca9783b7309 (patch) | |
tree | b5978aff26fa2650ca7cf9040bfb7c6c408ddd9b /Master/texmf-dist/scripts | |
parent | 26b44194fa3622fa961f40a0d62fb3cacaa5cbc9 (diff) |
splitindex (5apr13)
git-svn-id: svn://tug.org/texlive/trunk@29688 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/splitindex/splitindex.pl (renamed from Master/texmf-dist/scripts/splitindex/perl/splitindex.pl) | 0 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/splitindex/splitindex.tlu | 50 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/splitindex/splitindex_main.tlu | 187 |
3 files changed, 237 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/splitindex/perl/splitindex.pl b/Master/texmf-dist/scripts/splitindex/splitindex.pl index 70c61720c9b..70c61720c9b 100755 --- a/Master/texmf-dist/scripts/splitindex/perl/splitindex.pl +++ b/Master/texmf-dist/scripts/splitindex/splitindex.pl diff --git a/Master/texmf-dist/scripts/splitindex/splitindex.tlu b/Master/texmf-dist/scripts/splitindex/splitindex.tlu new file mode 100755 index 00000000000..a367634b037 --- /dev/null +++ b/Master/texmf-dist/scripts/splitindex/splitindex.tlu @@ -0,0 +1,50 @@ +#!/usr/bin/env texlua +-- splitindex.tlu +-- Copyright (c) Markus Kohm, 2013 +-- +-- $Id: splitindex.tlu,v 1.1 2013-04-04 11:28:17 mjk Exp $ +-- +-- This file is part of the SplitIndex bundle. +-- +-- This work may be distributed and/or modified under the conditions of +-- the LaTeX Project Public License, version 1.3c of the license. +-- The latest version of this license is in +-- http://www.latex-project.org/lppl.txt +-- and version 1.3c or later is part of all distributions of LaTeX +-- version 2005/12/01 or later and of this work. +-- +-- This work has the LPPL maintenance status "author-maintained". +-- +-- The Current Maintainer and author of this work is Markus Kohm. +-- +-- The list of all files belongig to the SplitIndex bundle is given in +-- in the file `manifest.txt'. Files generated by means of unpacking the +-- distribution (using, for example, the docstrip program) or by means +-- of compiling them from a source file, for example, from splitindex.c +-- or splitindex.java may be distributed at the distributor's discretion. +-- However if they are distributed then a copy of the SplitIndex bundle +-- must be distributed together with them. +-- +-- The list of derived (unpacked or compiled) files belongig to the +-- distribution and covered by LPPL is defined by the unpacking scripts +-- (with extension .ins) and the installation script (with name +-- install.sh) which are part of the distribution. +-- +-- Two often ignorred clauses from LPPL 1.3c you should not ignore: +-- ---------------------------------------------------------------- +-- 2. You may distribute a complete, unmodified copy of the Work as you +-- received it. Distribution of only part of the Work is considered +-- modification of the Work, and no right to distribute such a Derived +-- Work may be assumed under the terms of this clause. +-- 3. You may distribute a Compiled Work that has been generated from a +-- complete, unmodified copy of the Work as distributed under Clause 2 +-- above, as long as that Compiled Work is distributed in such a way that +-- the recipients may install the Compiled Work on their system exactly +-- as it would have been installed if they generated a Compiled Work +-- directly from the Work. + +kpse.set_program_name(arg[-1],'splitindex') +require('splitindex.splitindex_main') + +-- +-- End of file `splitindex.tlu' diff --git a/Master/texmf-dist/scripts/splitindex/splitindex_main.tlu b/Master/texmf-dist/scripts/splitindex/splitindex_main.tlu new file mode 100644 index 00000000000..1fc19b13fb2 --- /dev/null +++ b/Master/texmf-dist/scripts/splitindex/splitindex_main.tlu @@ -0,0 +1,187 @@ +#!/usr/bin/env texlua +-- splitindex.tlu +-- Copyright (c) Markus Kohm, 2013 +-- +-- $Id: splitindex_main.tlu,v 1.2 2013-04-04 13:59:54 mjk Exp $ +-- +-- This file is part of the SplitIndex bundle. +-- +-- This work may be distributed and/or modified under the conditions of +-- the LaTeX Project Public License, version 1.3c of the license. +-- The latest version of this license is in +-- http://www.latex-project.org/lppl.txt +-- and version 1.3c or later is part of all distributions of LaTeX +-- version 2005/12/01 or later and of this work. +-- +-- This work has the LPPL maintenance status "author-maintained". +-- +-- The Current Maintainer and author of this work is Markus Kohm. +-- +-- The list of all files belongig to the SplitIndex bundle is given in +-- in the file `manifest.txt'. Files generated by means of unpacking the +-- distribution (using, for example, the docstrip program) or by means +-- of compiling them from a source file, for example, from splitindex.c +-- or splitindex.java may be distributed at the distributor's discretion. +-- However if they are distributed then a copy of the SplitIndex bundle +-- must be distributed together with them. +-- +-- The list of derived (unpacked or compiled) files belongig to the +-- distribution and covered by LPPL is defined by the unpacking scripts +-- (with extension .ins) and the installation script (with name +-- install.sh) which are part of the distribution. +-- +-- Two often ignorred clauses from LPPL 1.3c you should not ignore: +-- ---------------------------------------------------------------- +-- 2. You may distribute a complete, unmodified copy of the Work as you +-- received it. Distribution of only part of the Work is considered +-- modification of the Work, and no right to distribute such a Derived +-- Work may be assumed under the terms of this clause. +-- 3. You may distribute a Compiled Work that has been generated from a +-- complete, unmodified copy of the Work as distributed under Clause 2 +-- above, as long as that Compiled Work is distributed in such a way that +-- the recipients may install the Compiled Work on their system exactly +-- as it would have been installed if they generated a Compiled Work +-- directly from the Work. + +local version_number = string.sub( '$Revision: 1.2 $', 12, -2 ) +local action_version = ' r'..version_number..'\n'..[[ +Copyright (c) 2013 Markus Kohm. +License: lppl 1.3c or later. See <http://www.latex-project.org/lppl.txt>. +]] +local action_help = [[ +options: + -h, --help Print this help message. + -i, --identify <regular expression> + Setup the regular expression to match the entries. + -m, --makeindex <program name> + Use <program name> instead of `makeindex'. + -r, --resultis <pattern> + Create line to be written from <pattern> after matching. + -s, --suffixis <pattern> + Create suffix to be used from <pattern> after matching. + -v, --verbose Be more verbose. + -V,--version Print the version information. +]] + +local action_opts = { + ['-h'] = 'help', + ['--help'] = 'help', + ['-i'] = 'identify', + ['--identify'] = 'identify', + ['-m'] = 'makeindex', + ['--makeindex'] = 'makeindex', + ['-r'] = 'resultis', + ['--resultis'] = 'resultis', + ['-s'] = 'suffixis', + ['--suffixis'] = 'suffixis', + ['-v'] = 'verbose', + ['--verbose'] = 'verbose', + ['-V'] = 'version', + ['--version'] = 'version', + ['--'] = '--', +} + +local identify = '^(\\indexentry)%[([^]]*)%](.*)$' +local makeindex = 'makeindex' +local resultis = '%1%3' +local suffixis = '-%2' +local verbose = 0 + +while arg[1] do + local action = action_opts[arg[1]] + if action == '--' then + table.remove(arg,1) + break + elseif action == 'help' then + print( arg[0]..action_version ) + print( 'Usage: ' .. arg[0] .. ' -h/--help' ) + print( ' ' .. arg[0] .. ' -V/--version' ) + print( ' ' .. arg[0] .. ' [<option> ...] \\ \ + <intermediate index file> \\ \ + [<makeindex option> ...]' ) + print( action_help ); + os.exit( 0 ); + elseif action == 'identify' then + table.remove(arg,1) + if arg[1] == nil then + error( 'value expected after option -i or --identify' ) + end + identify = arg[1] + table.remove(arg,1) + elseif action == 'makeindex' then + table.remove(arg,1) + if arg[1] == nil then + error( 'value expected after option -m or --makeindex' ) + end + makeindex = arg[1] + table.remove(arg,1) + elseif action == 'resultis' then + table.remove(arg,1) + if arg[1] == nil then + error( 'value expected after option -r or --resultis' ) + end + resultis = string.gsub(arg[1],'%$','%%') + table.remove(arg,1) + elseif action == 'suffixis' then + table.remove(arg,1) + if arg[1] == nil then + error( 'value expected after option -s or --suffixis' ) + end + suffixis = string.gsub(arg[1],'%$','%%') + table.remove(arg,1) + elseif action == 'verbose' then + table.remove(arg,1) + verbose = verbose + 1 + elseif action == 'version' then + print( arg[0] .. action_version ); + os.exit( 0 ); + else + break; + end +end + +if arg[1] == nil then + error( 'intermediate file missing' ) +end + +local ifilename = arg[1] +table.remove(arg,1) +local bfilename = string.gsub(ifilename,'^(.*)%.idx$','%1') + +local makeindexargs='' +while arg[1] do + makeindexargs = makeindexargs..' "'..arg[1]..'"' + table.remove(arg,1) +end + +local ofiles={} + +local line +for line in io.lines(ifilename) do + local newline=string.gsub(line,identify,resultis) + local ext,matches=string.gsub(line,identify,suffixis) + if matches == 0 then + ext = string.gsub(suffixis,'%%[1234567890]','idx') + end + if ofiles[ext] == nil then + local msg + ofiles[ext],msg = io.open(bfilename..ext..'.idx','w') + if ofiles[ext] == nil then error(msg) end + end + assert( ofiles[ext]:write(newline,"\n") ) +end + +local k,v +for k,v in pairs(ofiles) do + assert( v:close() ) + local cmd=makeindex..makeindexargs..' "'..bfilename..k..'.idx"' + if makeindex ~= '' then + local s,t,n=os.execute(cmd) + if not s then + error('failed to execute ' .. cmd ) + end + end +end + +-- +-- End of file `splitindex.tlu' |