diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-13 23:29:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-13 23:29:48 +0000 |
commit | 11b3c97585e0452103301352db8c4a79a317b11d (patch) | |
tree | 87371fa2183d1d06a502a500822c6f642b804746 /Master/texmf-dist/scripts | |
parent | 5e5a3249f60d40777380ce9a574ba915d1c0a25e (diff) |
ctan:support/m-tx/m-tx.texmf.zip
git-svn-id: svn://tug.org/texlive/trunk@26336 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/pmx/Windows/pmx.bat | 6 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pmx/pmx.lua | 154 |
2 files changed, 160 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/pmx/Windows/pmx.bat b/Master/texmf-dist/scripts/pmx/Windows/pmx.bat new file mode 100755 index 00000000000..6373c4d63aa --- /dev/null +++ b/Master/texmf-dist/scripts/pmx/Windows/pmx.bat @@ -0,0 +1,6 @@ +:: wrapper script to call pmx.lua
+:: Usage: pmx [options] basename[.pmx]
+:: Suggested by Tomasz Luczak (Tomek) t34www@googlemail.com
+
+@for /f "delims=" %%I in ('kpsewhich --format=texmfscripts %~n0.lua') do texlua "%%I" %*
+:end
diff --git a/Master/texmf-dist/scripts/pmx/pmx.lua b/Master/texmf-dist/scripts/pmx/pmx.lua new file mode 100755 index 00000000000..035c9515d93 --- /dev/null +++ b/Master/texmf-dist/scripts/pmx/pmx.lua @@ -0,0 +1,154 @@ +#!/usr/bin/env texlua + +VERSION = "0.2" + +--[[ + pmx.lua: processes MusiXTeX files using pmxab as a pre-processor (and deletes intermediate files) + + (c) Copyright 2011 Bob Tennent rdt@cs.queensu.ca + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +--]] + +--[[ + + ChangeLog: + version 0.2 2011-11-28 RDT + added -i (retain intermediate files) option + + version 0.1 2011-07-12 RDT + +--]] + +function usage() + print("Usage: [texlua] pmx.lua { option | basename[.pmx] } ... ") + print("options: -v version") + print(" -h help") + print(" -l latex (or pdflatex)") + print(" -p pdfetex (or pdflatex)") + print(" -d dvipdfm") + print(" -s stop at dvi") + print(" -t stop at tex/mid") + print(" -i retain intermediate files") + print(" -f restore default processing") +end + +function whoami () + print("This is pmx.lua version ".. VERSION .. ".") +end + +whoami() +if #arg == 0 then + usage() + os.exit(0) +end + +-- defaults: +tex = "etex" +musixflx = "musixflx" +dvi = "dvips" +ps2pdf = "ps2pdf" +intermediate = 1 + +exit_code = 0 +narg = 1 +repeat + this_arg = arg[narg] + if this_arg == "-v" then + os.exit(0) + elseif this_arg == "-h" then + usage() + os.exit(0) + elseif this_arg == "-l" then + if tex == "pdfetex" then + tex = "pdflatex" + else + tex = "latex" + end + elseif this_arg == "-p" then + if tex == "latex" then + tex = "pdflatex" + else + tex = "pdfetex" + end + dvi = ""; ps2pdf = "" + elseif this_arg == "-d" then + dvi = "dvipdfm"; ps2pdf = "" + elseif this_arg == "-s" then + dvi = ""; ps2pdf = "" + elseif this_arg == "-f" then + tex = "etex"; dvi = "dvips"; ps2pdf = "ps2pdf"; intermediate = 1 + elseif this_arg == "-t" then + tex = ""; dvi = ""; ps2pdf = "" + elseif this_arg == "-i" then + intermediate = 0 + else + filename = this_arg + if filename ~= "" and string.sub(filename, -4, -1) == ".pmx" then + filename = string.sub(filename, 1, -5) + end + if not io.open(filename .. ".pmx", "r") then + print("Non-existent file: ", filename .. ".pmx") + else + print("Processing ".. filename .. ".pmx.") + os.remove( filename .. ".mx2" ) + os.execute("pmxab" .. " " .. filename ) + pmxaerr = io.open("pmxaerr.dat", "r") + if (not pmxaerr) then + print("No log file.") + os.exit(1) + end + linebuf = pmxaerr:read() + err = tonumber(linebuf) + pmxaerr:close() + if ( err == 0 ) and + ((tex == "") or os.execute(tex .. " " .. filename) == 0) and + ((tex == "") or os.execute(musixflx .. " " .. filename) == 0) and + ((tex == "") or os.execute(tex .. " " .. filename) == 0) and + ((tex ~= "latex" and tex ~= "pdflatex") + or (os.execute(tex .. " " .. filename) == 0)) and + (dvi == "" or (os.execute(dvi .. " " .. filename) == 0)) and + (ps2pdf == "" or (os.execute(ps2pdf .. " " .. filename .. ".ps") == 0) ) + then + if ps2pdf ~= "" then + print(filename .. ".pdf generated by " .. ps2pdf .. ".") + end + if intermediate == 1 then -- clean-up: + os.remove( "pmxaerr.dat" ) + os.remove( filename .. ".mx1" ) + os.remove( filename .. ".mx2" ) + if dvi ~= "" then + os.remove( filename .. ".dvi" ) + end + if ps2pdf ~= "" then + os.remove( filename .. ".ps" ) + end + end + else + print("pmx/MusiXTeX processing of " .. filename .. ".pmx fails.\n") + exit_code = 2 + --[[ uncomment for debugging + print("tex = ", tex) + print("dvi = ", dvi) + print("ps2pdf = ", ps2pdf) + --]] + end + + end --if not io.open ... + end --if this_arg == ... + narg = narg+1 +until narg > #arg +os.exit( exit_code ) |