| 1 |
\newread\ptx@temp_read |
| 2 |
\def\iffile{% |
| 3 |
\ifnext[ |
| 4 |
{\ptx@iffile} |
| 5 |
{\ptx@iffile[]}% |
| 6 |
} |
| 7 |
\def\ptx@iffile[#1]#2{% |
| 8 |
\directlua{ |
| 9 |
local f = kpse.find_file("\luaescapestring{#2}"\reverse\iffemptystring{#1}{, "#1"}) |
| 10 |
local x = f and "firstoftwo" or "secondoftwo" |
| 11 |
tex.print(\the\texcatcodes, "\noexpand\\" .. x) |
| 12 |
}% |
| 13 |
} |
| 14 |
\long\def\ifffile{% |
| 15 |
\ifnext[ |
| 16 |
{\ptx@ifffile} |
| 17 |
{\ptx@ifffile[]}% |
| 18 |
} |
| 19 |
\long\def\ptx@ifffile[#1]#2#3{% |
| 20 |
\iffile[#1]{#2}{#3}{}% |
| 21 |
} |
| 22 |
|
| 23 |
\long\def\inputfileor{% |
| 24 |
\ifnext[ |
| 25 |
{\ptx@inputfileor} |
| 26 |
{\ptx@inputfileor[]}% |
| 27 |
} |
| 28 |
\long\def\ptx@inputfileor[#1]#2{% |
| 29 |
\iffile[#1]{#2}{\input{#2}\relax}% |
| 30 |
} |
| 31 |
|
| 32 |
\newwrite\ptx@auxfile |
| 33 |
\def\ptx@write_toaux{% |
| 34 |
\ifnext* |
| 35 |
{\gobbleoneand{\write\ptx@auxfile}} |
| 36 |
{\immediate\write\ptx@auxfile}% |
| 37 |
} |
| 38 |
|
| 39 |
\let\writeout\ptx@write_toaux |