diff options
author | Karl Berry <karl@freefriends.org> | 2011-05-22 22:09:37 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-05-22 22:09:37 +0000 |
commit | b2aad21b139ae68b8aa85a2d2767851a2d25343f (patch) | |
tree | 3a910b2189868edeeacc6e96e961d4e4cddf39cb /Build | |
parent | 086cd8809226250fa0a0a4f66ff59140ce871c11 (diff) |
musixtex 1.15 (22may11)
git-svn-id: svn://tug.org/texlive/trunk@22568 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/musixtex/musixtex.lua | 157 |
1 files changed, 80 insertions, 77 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/musixtex/musixtex.lua b/Build/source/texk/texlive/linked_scripts/musixtex/musixtex.lua index c567af06950..6bac25e8d8a 100755 --- a/Build/source/texk/texlive/linked_scripts/musixtex/musixtex.lua +++ b/Build/source/texk/texlive/linked_scripts/musixtex/musixtex.lua @@ -1,9 +1,9 @@ #!/usr/bin/env texlua -VERSION = "0.3" +VERSION = "0.4" --[[ - musixtex.lua: processes a MusiXTeX file and then deletes intermediate files + musixtex.lua: processes MusiXTeX files (and deletes intermediate files) (c) Copyright 2011 Bob Tennent rdt@cs.queensu.ca @@ -27,6 +27,10 @@ VERSION = "0.3" ChangeLog: + version 0.4 2011-04-30 RDT + Allow multiple filenames (and options). + Add -f (default) and -l (latex) options. + version 0.3 2011-04-25 RDT Add -d (dvipdfm) and -s (stop at dvi) options. @@ -38,30 +42,22 @@ VERSION = "0.3" --]] function usage() - print("Usage: [texlua] musixtex.lua [option] [basename[.tex]]") + print("Usage: [texlua] musixtex.lua { option | basename[.tex] } ... ") print("options: -v version") print(" -h help") - print(" -p pdfetex") + print(" -l latex (or pdflatex)") + print(" -p pdfetex (or pdflatex)") print(" -d dvipdfm") print(" -s stop at dvi") + print(" -f restore default processing") end function whoami () print("This is musixtex.lua version ".. VERSION .. ".") end +whoami() if #arg == 0 then - whoami() - usage() - os.exit(0) -end - -narg = 1 - -if arg[narg] == "-v" then - whoami() - os.exit(0) -elseif arg[narg] == "-h" then usage() os.exit(0) end @@ -69,70 +65,77 @@ end -- defaults: tex = "etex" musixflx = "musixflx" -dvi = "dvips -q" +dvi = "dvips" ps2pdf = "ps2pdf" -if narg < #arg then - if arg[narg] == "-p" then - tex = "pdfetex"; dvi = ""; ps2pdf = "" - elseif arg[narg] == "-d" then - tex = "etex"; dvi = "dvipdfm"; ps2pdf = "" - elseif arg[narg] == "-s" then - tex = "etex"; dvi = ""; ps2pdf = "" +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" else - print("Argument \"".. arg[narg] .. "\" ignored.") - end + filename = this_arg + if filename ~= "" and string.sub(filename, -4, -1) == ".tex" then + filename = string.sub(filename, 1, -5) + end + if not io.open(filename .. ".tex", "r") then + print("Non-existent file: ", filename .. ".tex") + else + print("Processing ".. filename .. ".tex.") + os.remove( filename .. ".mx2" ) + if (os.execute(tex .. " " .. filename) == 0) and + (os.execute(musixflx .. " " .. filename) == 0) and + (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 -- clean-up: + os.remove( filename .. ".mx1" ) + os.remove( filename .. ".mx2" ) + if dvi ~= "" then + os.remove( filename .. ".dvi" ) + end + if ps2pdf ~= "" then + print(filename .. ".pdf generated by " .. ps2pdf .. ".") + os.remove( filename .. ".ps" ) + end + print("") + else + print("Musixtex processing of " .. filename .. ".tex 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 -end - - -filename = arg[narg] -if not filename then - usage() - os.exit(1) -end - -extension = string.sub(filename, -4, -1) -if extension == ".tex" then - basename = string.sub(filename, 1, -5) -else - basename = filename -end - -if not io.open(basename .. ".tex", "r") then - print("Non-existent file: ", basename .. ".tex") - os.exit(2) -end - -whoami() -print("Processing ".. basename .. ".tex") -os.remove( basename .. ".mx2" ) -if (os.execute(tex .. " " .. basename) == 0) and - (os.execute(musixflx .. " " .. basename) == 0) and - (os.execute(tex .. " " .. basename) == 0) and - (dvi == "" or (os.execute(dvi .. " " .. basename) == 0)) and - (ps2pdf == "" or (os.execute(ps2pdf .. " " .. basename .. ".ps") == 0) ) -then - if dvi ~= "" then - print(basename .. ".pdf generated.") - end - exit_code = 0 -else - print("Musixtex processing fails.") ---[[ uncomment for debugging - print("tex = ", tex) - print("dvi = ", dvi) - print("ps2pdf = ", ps2pdf) ---]] - exit_code = 3 -end - --- clean-up: -os.remove( basename .. ".mx1" ) -os.remove( basename .. ".mx2" ) -if dvi ~= "" then - os.remove( basename .. ".dvi" ) -end -os.remove( basename .. ".ps" ) - +until narg > #arg os.exit( exit_code ) |