summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/tex/latex/latexconfig/lualatexquotejobname.tex26
1 files changed, 25 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/latex/latexconfig/lualatexquotejobname.tex b/Master/texmf-dist/tex/latex/latexconfig/lualatexquotejobname.tex
index 19a1f8845e1..bf70bad24ca 100644
--- a/Master/texmf-dist/tex/latex/latexconfig/lualatexquotejobname.tex
+++ b/Master/texmf-dist/tex/latex/latexconfig/lualatexquotejobname.tex
@@ -3,7 +3,21 @@
%
% Quote \jobname if it contains spaces, similarly to what pdfTeX does.
%
+% Recent versions of luatex kindly provide a process_jobname callback for
+% this. Detect if it is available and use a fallback in pure TeX otherwise.
+% If using the callback, register it at \everyjob time since callbacks are not
+% dumped in formats currently.
+%
+% The TeX version fails with "luatex '\input foo'" invocations, but it can
+% either support that or spaces in filenames, not both. This one is kept for
+% historical reasons.
+%
+% This file is inputed after latex.ltx.
+%
\everyjob\expandafter{\the\everyjob
+ \ifcase\directlua{
+ tex.sprint(callback.list().process_jobname == nil and 0 or 1)}\relax
+ % no callback, do what we can in TeX
\begingroup
\def\testsp#1 #2\relax{%
\ifx\relax#2\relax
@@ -12,5 +26,15 @@
\edef\fixjobname{\def\noexpand\jobname{"\jobname"}}%
\fi}%
\edef\dotest{\noexpand\testsp\jobname\space\relax}\dotest
- \expandafter\endgroup\fixjobname}
+ \expandafter\endgroup\fixjobname
+ \or % callback available, use it
+ \directlua{
+ callback.register('process_jobname', function(jobname)
+ if jobname:find(' ') then
+ return '"' .. jobname .. '"'
+ else
+ return jobname
+ end
+ end)}
+ \fi}
\endinput