summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/pitex/files.ptx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/plain/contrib/pitex/files.ptx')
-rw-r--r--macros/plain/contrib/pitex/files.ptx39
1 files changed, 39 insertions, 0 deletions
diff --git a/macros/plain/contrib/pitex/files.ptx b/macros/plain/contrib/pitex/files.ptx
new file mode 100644
index 0000000000..212b05fc07
--- /dev/null
+++ b/macros/plain/contrib/pitex/files.ptx
@@ -0,0 +1,39 @@
+\newread\ptx@temp_read
+\def\iffile{%
+ \ifnext[
+ {\ptx@iffile}
+ {\ptx@iffile[]}%
+ }
+\def\ptx@iffile[#1]#2{%
+ \directlua{
+ local f = kpse.find_file("\luaescapestring{#2}"\reverse\iffemptystring{#1}{, "#1"})
+ local x = f and "firstoftwo" or "secondoftwo"
+ tex.print(\the\texcatcodes, "\noexpand\\" .. x)
+ }%
+ }
+\long\def\ifffile{%
+ \ifnext[
+ {\ptx@ifffile}
+ {\ptx@ifffile[]}%
+ }
+\long\def\ptx@ifffile[#1]#2#3{%
+ \iffile[#1]{#2}{#3}{}%
+ }
+
+\long\def\inputfileor{%
+ \ifnext[
+ {\ptx@inputfileor}
+ {\ptx@inputfileor[]}%
+ }
+\long\def\ptx@inputfileor[#1]#2{%
+ \iffile[#1]{#2}{\input{#2}\relax}%
+ }
+
+\newwrite\ptx@auxfile
+\def\ptx@write_toaux{%
+ \ifnext*
+ {\gobbleoneand{\write\ptx@auxfile}}
+ {\immediate\write\ptx@auxfile}%
+ }
+
+\let\writeout\ptx@write_toaux