summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/latexconfig
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2011-06-13 20:49:26 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2011-06-13 20:49:26 +0000
commit9973b21436367150431795d9d876ee900397d5fb (patch)
tree2ff149ffcd1c1e11d194a59b25a9e389b050e837 /Master/texmf-dist/tex/latex/latexconfig
parentef3c7e7a48e6c380e45d65b56a12808aef8d5d16 (diff)
lualatexquotejobname: use callback if available
(tested with luatex 0.71-trunk) git-svn-id: svn://tug.org/texlive/trunk@22957 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/latexconfig')
-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