summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/ptex2pdf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-06-16 21:19:33 +0000
committerKarl Berry <karl@freefriends.org>2015-06-16 21:19:33 +0000
commitaabaf017d9f80254268cc35b62b781ad9dc598f6 (patch)
tree9e653c8221bdaf1f729803854928f01bcce99f5b /Master/texmf-dist/scripts/ptex2pdf
parent42f448fd67c0906edfb3bf8ad7c7a6e336e31da0 (diff)
ptex2pdf (16jun15)
git-svn-id: svn://tug.org/texlive/trunk@37566 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/ptex2pdf')
-rwxr-xr-xMaster/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua96
1 files changed, 59 insertions, 37 deletions
diff --git a/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua b/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua
index f6e4fc0fbb6..3b0c5b5d62b 100755
--- a/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua
+++ b/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua
@@ -1,7 +1,7 @@
#!/usr/bin/env texlua
NAME = "ptex2pdf[.lua]"
-VERSION = "0.7"
+VERSION = "0.8"
AUTHOR = "Norbert Preining"
AUTHOREMAIL = "norbert@preining.info"
SHORTDESC = "Convert Japanese TeX documents to pdf"
@@ -152,11 +152,14 @@ CHANGELOG = [[
cygwin didn't like the (accidentally inserted) spaces after the
texlua in the shebang line, and stopped working with
"no such program: "texlua " ..."
-- version 0.7dev 2015-XX-XX
+- version 0.7 2015-04-29
move to github as gitorious will be closed, adapt help output
to generate github flavored markdown
check for files using kpathsea instead of opening directly, to allow
for input of files found by kpathsea (closes github issue 1)
+- version 0.8 2015-06-15
+ file name checks: first search for arg as is, then try .tex and .ltx
+ (closes github issue: 3)
]]
@@ -247,6 +250,7 @@ use_eptex = 0
use_uptex = 0
use_latex = 0
filename = ""
+bname = ""
exit_code = 0
narg = 1
repeat
@@ -323,46 +327,64 @@ end
-- initialize kpse
kpse.set_program_name(tex)
-if filename ~= "" and string.sub(filename, -4, -1) == ".tex" then
- filename = string.sub(filename, 1, -5)
+-- filename searching
+-- first search for the file as is,
+-- if not found, try file .tex, if that not found, file .ltx
+
+if ( filename == "" ) then
+ print("No filename argument given, exiting.")
+ os.exit(1)
+else
+ if ( kpse.find_file(filename) == nil ) then
+ -- try .tex extension
+ if ( kpse.find_file(filename .. ".tex") == nil ) then
+ -- last try .ltx
+ if ( kpse.find_file(filename .. ".ltx") == nil ) then
+ print("File cannot be found with kpathsea: ", filename .. "[.tex, .ltx]")
+ os.exit(1)
+ else
+ bname = filename
+ filename = filename .. ".ltx"
+ end
+ else
+ bname = filename
+ filename = filename .. ".tex"
+ end
+ else
+ -- if it has already an extension, we need to drop it to get the dvi name
+ bname = string.gsub(filename, "^(.*)%.[^.]+$", "%1")
+ end
end
--- if not io.open(filename .. ".tex", "r") then
--- print("Non-existent file: ", filename .. ".tex")
--- exit_code = 1
-if ( kpse.find_file(filename .. ".tex") == nil ) then
- print("File cannot be found with kpathsea: ", filename .. ".tex")
- exit_code = 1
-else
- -- make sure that on Windows/uptex we are using utf8 as command line encoding
- if use_uptex == 1 then
- if os.type == 'windows' then
- os.setenv('command_line_encoding', 'utf8')
- end
+-- we are still here, so we found a file
+-- make sure that on Windows/uptex we are using utf8 as command line encoding
+if use_uptex == 1 then
+ if os.type == 'windows' then
+ os.setenv('command_line_encoding', 'utf8')
end
- print("Processing ".. filename .. ".tex.")
- if (os.execute(tex .. " " .. texopts .. " \"" .. filename .. "\"") == 0) and
- (dvipdf == "" or (os.execute(dvipdf .. " " .. dvipdfopts .. " \"" .. filename .. "\"") == 0))
- then
- if dvipdf ~= "" then
- print(filename .. ".pdf generated by " .. dvipdf .. ".")
- end
- if intermediate == 1 then -- clean-up:
- if dvipdf ~= "" then
- os.remove( filename .. ".dvi" )
- end
- end
- else
- print("ptex2pdf processing of " .. filename .. ".tex fails.\n")
- exit_code = 2
- --[[ uncomment for debugging
- print("tex = ", tex)
- print("dvipdf = ", dvipdf)
- --]]
+end
+print("Processing ".. filename)
+if (os.execute(tex .. " " .. texopts .. " \"" .. filename .. "\"") == 0) and
+ (dvipdf == "" or (os.execute(dvipdf .. " " .. dvipdfopts .. " \"" .. bname .. ".dvi" .. "\"") == 0)) then
+ if dvipdf ~= "" then
+ print(bname .. ".pdf generated by " .. dvipdf .. ".")
+ end
+ if intermediate == 1 then -- clean-up:
+ if dvipdf ~= "" then
+ os.remove( bname .. ".dvi" )
end
-end --if not io.open ...
+ end
+else
+ print("ptex2pdf processing of " .. filename .. " failed.\n")
+ --[[ uncomment for debugging
+ print("tex = ", tex)
+ print("dvipdf = ", dvipdf)
+ --]]
+ os.exit(2)
+end
-os.exit( exit_code )
+-- all done ... exit with success
+os.exit( 0 )