Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Patch to remove the \newwrite allocations made by the TikZ external library
This patch is for PGF-2.10
diff --git a/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex b/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
index d8eaca5..b860e51 100644
--- a/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
+++ b/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
@@ -391,16 +391,16 @@
}%
\def\pgf@externalend@storeshifts#1{%
- \immediate\write#1{\the\dp\pgfpic}% store the depth simply as number for backw. compat.
+ \immediate\writew@pgf@writea{\the\dp\pgfpic}% store the depth simply as number for backw. compat.
\ifx\pgf@trimleft@final\pgfutil@empty\else
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimleft{\pgf@trimleft@final}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimleft{\pgf@trimleft@final}}}%
\fi
\ifx\pgf@trimright@final\pgfutil@empty\else
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimright{\pgf@trimright@final}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimright{\pgf@trimright@final}}}%
\fi
\ifpgfexternal@info
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalwidth{\the\wd\pgfpic}}}%
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalheight{\the\dimen0}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalwidth{\the\wd\pgfpic}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalheight{\the\dimen0}}}%
\fi
}
% REMARK:
@@ -451,9 +451,9 @@
\pgf@externalend@storeshifts\@auxout
\immediate\closeout\@auxout
\else
- \immediate\openout\pgf@plotwrite=\pgf@filename.dpth
- \pgf@externalend@storeshifts\pgf@plotwrite
- \immediate\closeout\pgf@plotwrite
+ \immediate\openw@pgf@writea{\pgf@filename.dpth}
+ \pgf@externalend@storeshifts{}
+ \immediate\closew@pgf@writea
\fi
\fi
\pgfsys@papersize{\the\wd\pgfpic}{\the\dimen0}%
diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
index 8c22215..41f75d3 100644
--- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
+++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
@@ -26,7 +26,52 @@
\toksdef\t@tikzexternal@tmpa=0
\toksdef\t@tikzexternal@tmpb=1
-\newwrite\tikzexternal@outfile
+\newcommand\opentikzexternal@outfile[1]{\directlua{
+ if not tikz_outfile == nil then
+ tikz_outfile:close()
+ end
+
+ tikz_outfile = io.open("#1", "w")
+}}
+\newcommand\closetikzexternal@outfile{\directlua{
+ if not tikz_outfile == nil then
+ tikz_outfile:close()
+ end
+}}
+\newcommand\writetikzexternal@outfile[1]{\directlua{tikz_outfile:write("#1\string\n")}}
+
+
+\newcommand\opentikzexternal@dep@file[1]{\directlua{
+ if not tikz_depfile == nil then
+ tikz_depfile:close()
+ end
+
+ tikz_depfile = io.open("#1", "w")
+}}
+\newcommand\closetikzexternal@dep@file{\directlua{
+ if not tikz_depfile == nil then
+ tikz_depfile:close()
+ end
+}}
+\newcommand\writetikzexternal@dep@file[1]{\directlua{tikz_depfile:write("#1\string\n")}}
+
+
+\newcommand\opentikzexternal@outmakefile[1]{\directlua{
+ if not tikz_outmakefile == nil then
+ tikz_outmakefile:close()
+ end
+
+ tikz_outmakefile = io.open("#1", "w")
+}}
+\newcommand\closetikzexternal@outmakefile{\directlua{
+ if not tikz_outmakefile == nil then
+ tikz_outmakefile:close()
+ end
+}}
+\newcommand\writetikzexternal@outmakefile[1]{\directlua{tikz_outmakefile:write("#1\string\n")}}
+
+
+%\newwrite\tikzexternal@outfile
\newif\iftikzexternal@nestedflag
\newif\iftikzexternal@verboseio
\newif\iftikzexternal@genfigurelist
@@ -135,7 +180,7 @@
\pgfkeysalso{/tikz/external/figure list=true,/pgf/images/aux in dpth=true}%
},
mode=convert with system call,
- system call/.initial={pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},
+ system call/.initial={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},
% system call/.initial={pdflatex -interaction=batchmode -jobname '\image' '\texsource'; pdftops -eps \image.pdf},
force remake/.is if=tikzexternal@force@remake,
force remake/.default=true,
@@ -413,9 +458,9 @@
\closein\r@pgf@reada
}%
\def\tikzexternalauxlock@setlock#1{%
- \immediate\openout\w@pgf@writea=\tikzexternal@realjob.auxlock
- \immediate\write\w@pgf@writea{\noexpand\def\noexpand\tikzexternallocked{#1}}%
- \immediate\closeout\w@pgf@writea
+ \immediate\openw@pgf@writea{\tikzexternal@realjob.auxlock}
+ \immediate\writew@pgf@writea{\noexpand\def\noexpand\tikzexternallocked{#1}}%
+ \immediate\closew@pgf@writea
}
@@ -792,7 +837,7 @@
\else
\pgfutil@ifundefined{tikzexternal@listmode@openedfile}{%
\message{Opening '\tikzexternal@realjob.figlist' for writing.}%
- \immediate\openout\tikzexternal@outfile=\tikzexternal@realjob.figlist\relax
+ \immediate\opentikzexternal@outfile{\tikzexternal@realjob.figlist}\relax
\gdef\tikzexternal@listmode@openedfile{1}%
\if\tikzexternal@opmode5% mode='list and make'
\tikzexternal@list@and@make@prepare
@@ -801,7 +846,7 @@
\iftikzexternal@verboseio
\immediate\write16{Writing '#1' to '\tikzexternal@realjob.figlist'.}%
\fi
- \immediate\write\tikzexternal@outfile{#1}%
+ \immediate\writetikzexternal@outfile{#1}%
\if\tikzexternal@opmode5% mode='list and make'
\tikzexternal@list@and@make@gentarget{#1}%
\fi
@@ -817,9 +862,9 @@
\fi
\global\tikzexternal@file@isuptodatetrue% only check for force remake:
\tikzexternal@checkforceremake%
- \immediate\write\tikzexternal@outmakefile{#1\tikzexternalimgextension: \iftikzexternal@file@isuptodate\else FORCEREMAKE\fi}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar\pgf@tempa}%
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{#1\tikzexternalimgextension: \iftikzexternal@file@isuptodate\else FORCEREMAKE\fi}%
+ \immediate\writetikzexternal@outmakefile{\luaescapestring{\tikzexternal@TABchar\pgf@tempa}}%
+ \immediate\writetikzexternal@outmakefile{}%
}
\def\tikzexternal@list@and@make@prepare{%
@@ -830,23 +875,23 @@
% this makes \tikzexternal@outmakefile global:
\globaldefs=1
% this gets round '\outer\newwrite' in plain TeX:
- \csname newwrite\endcsname\tikzexternal@outmakefile
+ % \csname newwrite\endcsname\tikzexternal@outmakefile
\endgroup
- \immediate\openout\tikzexternal@outmakefile=\tikzexternal@realjob.makefile\relax
- \immediate\write\tikzexternal@outmakefile{ALL_FIGURE_NAMES=\tikzexternal@DOLLARchar(shell cat \tikzexternal@realjob.figlist)}%
- \immediate\write\tikzexternal@outmakefile{ALL_FIGURES=\tikzexternal@DOLLARchar(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar\tikzexternalimgextension)}%
- \immediate\write\tikzexternal@outmakefile{}%
- \immediate\write\tikzexternal@outmakefile{allimages: \tikzexternal@DOLLARchar(ALL_FIGURES)}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar @echo All images exist now. Use make -B to re-generate them.}%
- \immediate\write\tikzexternal@outmakefile{}%
- \immediate\write\tikzexternal@outmakefile{FORCEREMAKE:}%
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\opentikzexternal@outmakefile{\tikzexternal@realjob.makefile}\relax
+ \immediate\writetikzexternal@outmakefile{ALL_FIGURE_NAMES=\tikzexternal@DOLLARchar(shell cat \tikzexternal@realjob.figlist)}%
+ \immediate\writetikzexternal@outmakefile{ALL_FIGURES=\tikzexternal@DOLLARchar(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar\tikzexternalimgextension)}%
+ \immediate\writetikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{allimages: \tikzexternal@DOLLARchar(ALL_FIGURES)}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar @echo All images exist now. Use make -B to re-generate them.}%
+ \immediate\writetikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{FORCEREMAKE:}%
+ \immediate\writetikzexternal@outmakefile{}%
%
% support for .dep files and auto-dependencies:
- \immediate\write\tikzexternal@outmakefile{include $(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar.\tikzexternaldepext)}%
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{include $(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar.\tikzexternaldepext)}%
+ \immediate\writetikzexternal@outmakefile{}%
\tikzexternalmakefiledefaultdeprule
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{}%
\tikzexternal@outmakefile@pendingcommands
\pgfutil@ifundefined{AtEndDocument}{}{%
\AtEndDocument{\immediate\write16{===== mode=`list and make': Use 'make -f \tikzexternal@realjob.makefile' to generate all images. Then, re-run (pdf)latex \tikzexternal@realjob. =====}}%
@@ -855,8 +900,8 @@
\def\tikzexternaldepext{dep}
\def\tikzexternalmakefiledefaultdeprule{%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
}%
% Invokes '#1' if a makefile is to be written and '#2' if not.
@@ -868,13 +913,9 @@
% Will write something to the make file. If the makefile is not yet
% opened, #1 will be written as soon as it *is* opened.
\def\tikzexternalwritetomakefile#1{%
- \pgfutil@ifundefined{tikzexternal@outmakefile}{%
\expandafter\gdef\expandafter\tikzexternal@outmakefile@pendingcommands\expandafter{%
\tikzexternal@outmakefile@pendingcommands
\immediate\write\tikzexternal@outmakefile{#1}%
- }%
- }{%
- \immediate\write\tikzexternal@outmakefile{#1}%
}%
}%
@@ -900,24 +941,10 @@
\ifx\tikzexternal@dep@file@name\tikzpicturedependsonfile@name
% file is open and ready.
\else
- % create new output file.
- \pgfutil@ifundefined{tikzexternal@dep@file}{%
- \begingroup
- % this makes \tikzexternal@dep@file global:
- \globaldefs=1
- % this gets round '\outer\newwrite' in plain TeX:
- \csname newwrite\endcsname\tikzexternal@dep@file
- \endgroup
- }{}%
- \ifx\tikzexternal@dep@file@name\pgfutil@empty
- \else
- % it is already open. Close it.
- \immediate\closeout\tikzexternal@dep@file
- \fi
\global\let\tikzexternal@dep@file@name=\tikzpicturedependsonfile@name
- \immediate\openout\tikzexternal@dep@file=\tikzexternal@dep@file@name\relax
+ \immediate\opentikzexternal@dep@file{\tikzexternal@dep@file@name}\relax
\fi
- \immediate\write\tikzexternal@dep@file{#1\tikzexternalimgextension: #2}%
+ \immediate\writetikzexternal@dep@file{#1\tikzexternalimgextension: #2}%
\fi
\endgroup
}%
diff --git a/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex b/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex
index 1043825..cd99879 100644
--- a/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex
+++ b/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex
@@ -349,12 +349,12 @@
\multiply\c@pgf@countd by60
\c@pgf@countc=\time
\advance\c@pgf@countc by-\c@pgf@countd
- \immediate\openout\w@pgf@writea=\jobname.profiler.\the\year-\pgfprofiletotwodigitstr\month-\pgfprofiletotwodigitstr\day_\pgfprofiletotwodigitstr\c@pgf@countb h_\pgfprofiletotwodigitstr\c@pgf@countc m.dat
- \immediate\write\w@pgf@writea{%
+ \immediate\openw@pgf@writea{\jobname.profiler.\the\year-\pgfprofiletotwodigitstr\month-\pgfprofiletotwodigitstr\day_\pgfprofiletotwodigitstr\c@pgf@countb h_\pgfprofiletotwodigitstr\c@pgf@countc m.dat}
+ \immediate\writew@pgf@writea{%
\pgfprofile@percent relative values are measured against the totaltime of `\pgfprofile@rel'.%
}%
\immediate\write16{pgflibraryprofiler: relative values are measured against the totaltime of `\pgfprofile@rel'.}%
- \immediate\write\w@pgf@writea{%
+ \immediate\writew@pgf@writea{%
profilerentry\pgfprofile@TAB
totaltime[s]\pgfprofile@TAB
totaltime[percent]\pgfprofile@TAB
@@ -379,10 +379,10 @@
}{}%
\pgfprofilepostprocess@single{##1}%
}%
- \immediate\write\w@pgf@writea{%
+ \immediate\writew@pgf@writea{%
\pgfprofile@percent\space vim: ts=40 nowrap nostartofline
}%
- \immediate\closeout\w@pgf@writea
+ \immediate\closew@pgf@writea
\endgroup
}%
@@ -419,7 +419,7 @@
invocations=\csname c@pgfprofile@numinvocations@#1\endcsname;
\pgfprofile@rbrace
}%
- \immediate\write\w@pgf@writea{%
+ \immediate\writew@pgf@writea{%
#1\pgfprofile@TAB
\pgfprofilecur@total\pgfprofile@TAB
\pgfprofilecur@total@rel\pgfprofile@TAB
diff --git a/tex/generic/pgf/modules/pgfmoduleplot.code.tex b/tex/generic/pgf/modules/pgfmoduleplot.code.tex
index ea55ca8..09c99c2 100644
--- a/tex/generic/pgf/modules/pgfmoduleplot.code.tex
+++ b/tex/generic/pgf/modules/pgfmoduleplot.code.tex
@@ -311,7 +311,7 @@
\xdef\pgf@gnuplot@head{set table \noexpand\pgf@plottablefile@quoted; set format "%.5f"}
}
-\let\pgf@plotwrite=\w@pgf@writea
+% \let\pgf@plotwrite=\w@pgf@writea
\newif\ifpgf@resample@plot
\def\pgfplotgnuplot{\pgfutil@ifnextchar[{\pgf@plotgnuplot}{\pgf@plotgnuplot[\jobname]}}%}
diff --git a/tex/generic/pgf/systemlayer/pgfsys.code.tex b/tex/generic/pgf/systemlayer/pgfsys.code.tex
index 3cd39c4..ee8a73e 100644
--- a/tex/generic/pgf/systemlayer/pgfsys.code.tex
+++ b/tex/generic/pgf/systemlayer/pgfsys.code.tex
@@ -56,7 +56,24 @@
\newdimen\pgf@xc
\newdimen\pgf@yc
-\newwrite\w@pgf@writea
+
+\newcommand\openw@pgf@writea[1]{\directlua{
+ if not w_pgf_writea == nil then
+ w_pgf_writea:close()
+ end
+
+ w_pgf_writea = io.open("\luaescapestring{#1}", "w")
+}}
+
+\newcommand\closew@pgf@writea{\directlua{
+ if not w_pgf_writea == nil then
+ w_pgf_writea:close()
+ end
+}}
+
+\newcommand\writew@pgf@writea[1]{\directlua{w_pgf_writea:write("\luaescapestring{#1}\string\n")}}
+%\newwrite\w@pgf@writea
+
\newread\r@pgf@reada
\let\pgfutil@inputcheck=\r@pgf@reada
This patch is for the version of PGF in TLcontrib. It may or may not work.
diff --git a/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex b/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
index d8eaca5..b860e51 100644
--- a/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
+++ b/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
@@ -391,16 +391,16 @@
}%
\def\pgf@externalend@storeshifts#1{%
- \immediate\write#1{\the\dp\pgfpic}% store the depth simply as number for backw. compat.
+ \immediate\writew@pgf@writea{\the\dp\pgfpic}% store the depth simply as number for backw. compat.
\ifx\pgf@trimleft@final\pgfutil@empty\else
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimleft{\pgf@trimleft@final}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimleft{\pgf@trimleft@final}}}%
\fi
\ifx\pgf@trimright@final\pgfutil@empty\else
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimright{\pgf@trimright@final}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimright{\pgf@trimright@final}}}%
\fi
\ifpgfexternal@info
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalwidth{\the\wd\pgfpic}}}%
- \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalheight{\the\dimen0}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalwidth{\the\wd\pgfpic}}}%
+ \immediate\writew@pgf@writea{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalheight{\the\dimen0}}}%
\fi
}
% REMARK:
@@ -451,9 +451,9 @@
\pgf@externalend@storeshifts\@auxout
\immediate\closeout\@auxout
\else
- \immediate\openout\pgf@plotwrite=\pgf@filename.dpth
- \pgf@externalend@storeshifts\pgf@plotwrite
- \immediate\closeout\pgf@plotwrite
+ \immediate\openw@pgf@writea{\pgf@filename.dpth}
+ \pgf@externalend@storeshifts{}
+ \immediate\closew@pgf@writea
\fi
\fi
\pgfsys@papersize{\the\wd\pgfpic}{\the\dimen0}%
diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
index 791382b..722b7cf 100644
--- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
+++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
@@ -26,7 +26,52 @@
\toksdef\t@tikzexternal@tmpa=0
\toksdef\t@tikzexternal@tmpb=1
-\newwrite\tikzexternal@outfile
+\newcommand\opentikzexternal@outfile[1]{\directlua{
+ if not tikz_outfile == nil then
+ tikz_outfile:close()
+ end
+
+ tikz_outfile = io.open("#1", "w")
+}}
+\newcommand\closetikzexternal@outfile{\directlua{
+ if not tikz_outfile == nil then
+ tikz_outfile:close()
+ end
+}}
+\newcommand\writetikzexternal@outfile[1]{\directlua{tikz_outfile:write("#1\string\n")}}
+
+
+\newcommand\opentikzexternal@dep@file[1]{\directlua{
+ if not tikz_depfile == nil then
+ tikz_depfile:close()
+ end
+
+ tikz_depfile = io.open("#1", "w")
+}}
+\newcommand\closetikzexternal@dep@file{\directlua{
+ if not tikz_depfile == nil then
+ tikz_depfile:close()
+ end
+}}
+\newcommand\writetikzexternal@dep@file[1]{\directlua{tikz_depfile:write("#1\string\n")}}
+
+
+\newcommand\opentikzexternal@outmakefile[1]{\directlua{
+ if not tikz_outmakefile == nil then
+ tikz_outmakefile:close()
+ end
+
+ tikz_outmakefile = io.open("#1", "w")
+}}
+\newcommand\closetikzexternal@outmakefile{\directlua{
+ if not tikz_outmakefile == nil then
+ tikz_outmakefile:close()
+ end
+}}
+\newcommand\writetikzexternal@outmakefile[1]{\directlua{tikz_outmakefile:write("#1\string\n")}}
+
+
+%\newwrite\tikzexternal@outfile
\newif\iftikzexternal@nestedflag
\newif\iftikzexternal@verboseio
\newif\iftikzexternal@genfigurelist
@@ -135,7 +180,7 @@
\pgfkeysalso{/tikz/external/figure list=true,/pgf/images/aux in dpth=true}%
},
mode=convert with system call,
- system call/.initial={pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},
+ system call/.initial={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},
% system call/.initial={pdflatex -interaction=batchmode -jobname '\image' '\texsource'; pdftops -eps \image.pdf},
force remake/.is if=tikzexternal@force@remake,
force remake/.default=true,
@@ -421,9 +466,9 @@
\closein\r@pgf@reada
}%
\def\tikzexternalauxlock@setlock#1{%
- \immediate\openout\w@pgf@writea=\tikzexternal@realjob.auxlock
- \immediate\write\w@pgf@writea{\noexpand\def\noexpand\tikzexternallocked{#1}}%
- \immediate\closeout\w@pgf@writea
+ \immediate\openw@pgf@writea{\tikzexternal@realjob.auxlock}
+ \immediate\writew@pgf@writea{\noexpand\def\noexpand\tikzexternallocked{#1}}%
+ \immediate\closew@pgf@writea
}
@@ -800,7 +845,7 @@
\else
\pgfutil@ifundefined{tikzexternal@listmode@openedfile}{%
\message{Opening '\tikzexternal@realjob.figlist' for writing.}%
- \immediate\openout\tikzexternal@outfile=\tikzexternal@realjob.figlist\relax
+ \immediate\opentikzexternal@outfile{\tikzexternal@realjob.figlist}\relax
\gdef\tikzexternal@listmode@openedfile{1}%
\if\tikzexternal@opmode5% mode='list and make'
\tikzexternal@list@and@make@prepare
@@ -809,7 +854,7 @@
\iftikzexternal@verboseio
\immediate\write16{Writing '#1' to '\tikzexternal@realjob.figlist'.}%
\fi
- \immediate\write\tikzexternal@outfile{#1}%
+ \immediate\writetikzexternal@outfile{#1}%
\if\tikzexternal@opmode5% mode='list and make'
\tikzexternal@list@and@make@gentarget{#1}%
\fi
@@ -828,9 +873,9 @@
\fi
\global\tikzexternal@file@isuptodatetrue% only check for force remake:
\tikzexternal@checkforceremake%
- \immediate\write\tikzexternal@outmakefile{#1\tikzexternalimgextension: \iftikzexternal@file@isuptodate\else FORCEREMAKE\fi}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar\pgf@tempa}%
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{#1\tikzexternalimgextension: \iftikzexternal@file@isuptodate\else FORCEREMAKE\fi}%
+ \immediate\writetikzexternal@outmakefile{\luaescapestring{\tikzexternal@TABchar\pgf@tempa}}%
+ \immediate\writetikzexternal@outmakefile{}%
}
\def\tikzexternal@list@and@make@prepare{%
@@ -841,23 +886,23 @@
% this makes \tikzexternal@outmakefile global:
\globaldefs=1
% this gets round '\outer\newwrite' in plain TeX:
- \csname newwrite\endcsname\tikzexternal@outmakefile
+ % \csname newwrite\endcsname\tikzexternal@outmakefile
\endgroup
- \immediate\openout\tikzexternal@outmakefile=\tikzexternal@realjob.makefile\relax
- \immediate\write\tikzexternal@outmakefile{ALL_FIGURE_NAMES=\tikzexternal@DOLLARchar(shell cat \tikzexternal@realjob.figlist)}%
- \immediate\write\tikzexternal@outmakefile{ALL_FIGURES=\tikzexternal@DOLLARchar(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar\tikzexternalimgextension)}%
- \immediate\write\tikzexternal@outmakefile{}%
- \immediate\write\tikzexternal@outmakefile{allimages: \tikzexternal@DOLLARchar(ALL_FIGURES)}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar @echo All images exist now. Use make -B to re-generate them.}%
- \immediate\write\tikzexternal@outmakefile{}%
- \immediate\write\tikzexternal@outmakefile{FORCEREMAKE:}%
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\opentikzexternal@outmakefile{\tikzexternal@realjob.makefile}\relax
+ \immediate\writetikzexternal@outmakefile{ALL_FIGURE_NAMES=\tikzexternal@DOLLARchar(shell cat \tikzexternal@realjob.figlist)}%
+ \immediate\writetikzexternal@outmakefile{ALL_FIGURES=\tikzexternal@DOLLARchar(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar\tikzexternalimgextension)}%
+ \immediate\writetikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{allimages: \tikzexternal@DOLLARchar(ALL_FIGURES)}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar @echo All images exist now. Use make -B to re-generate them.}%
+ \immediate\writetikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{FORCEREMAKE:}%
+ \immediate\writetikzexternal@outmakefile{}%
%
% support for .dep files and auto-dependencies:
- \immediate\write\tikzexternal@outmakefile{include $(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar.\tikzexternaldepext)}%
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{include $(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar.\tikzexternaldepext)}%
+ \immediate\writetikzexternal@outmakefile{}%
\tikzexternalmakefiledefaultdeprule
- \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\writetikzexternal@outmakefile{}%
\tikzexternal@outmakefile@pendingcommands
\pgfutil@ifundefined{AtEndDocument}{}{%
\AtEndDocument{\immediate\write16{===== mode=`list and make': Use 'make -f \tikzexternal@realjob.makefile' to generate all images. Then, re-run (pdf)latex \tikzexternal@realjob. =====}}%
@@ -866,9 +911,9 @@
\def\tikzexternaldepext{dep}
\def\tikzexternalmakefiledefaultdeprule{%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
}%
% Invokes '#1' if a makefile is to be written and '#2' if not.
@@ -880,13 +925,9 @@
% Will write something to the make file. If the makefile is not yet
% opened, #1 will be written as soon as it *is* opened.
\def\tikzexternalwritetomakefile#1{%
- \pgfutil@ifundefined{tikzexternal@outmakefile}{%
\expandafter\gdef\expandafter\tikzexternal@outmakefile@pendingcommands\expandafter{%
\tikzexternal@outmakefile@pendingcommands
\immediate\write\tikzexternal@outmakefile{#1}%
- }%
- }{%
- \immediate\write\tikzexternal@outmakefile{#1}%
}%
}%
@@ -912,24 +953,10 @@
\ifx\tikzexternal@dep@file@name\tikzpicturedependsonfile@name
% file is open and ready.
\else
- % create new output file.
- \pgfutil@ifundefined{tikzexternal@dep@file}{%
- \begingroup
- % this makes \tikzexternal@dep@file global:
- \globaldefs=1
- % this gets round '\outer\newwrite' in plain TeX:
- \csname newwrite\endcsname\tikzexternal@dep@file
- \endgroup
- }{}%
- \ifx\tikzexternal@dep@file@name\pgfutil@empty
- \else
- % it is already open. Close it.
- \immediate\closeout\tikzexternal@dep@file
- \fi
\global\let\tikzexternal@dep@file@name=\tikzpicturedependsonfile@name
- \immediate\openout\tikzexternal@dep@file=\tikzexternal@dep@file@name\relax
+ \immediate\opentikzexternal@dep@file{\tikzexternal@dep@file@name}\relax
\fi
- \immediate\write\tikzexternal@dep@file{#1\tikzexternalimgextension: #2}%
+ \immediate\writetikzexternal@dep@file{#1\tikzexternalimgextension: #2}%
\fi
\endgroup
}%
diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.orig b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.orig
index 7899f03..791382b 100644
--- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.orig
+++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.orig
@@ -866,9 +866,9 @@
\def\tikzexternaldepext{dep}
\def\tikzexternalmakefiledefaultdeprule{%
- \immediate\writetikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
- \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}%
- \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
}%
% Invokes '#1' if a makefile is to be written and '#2' if not.
diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.rej b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.rej
index 1e72374..b685df2 100644
--- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.rej
+++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex.rej
@@ -1,20 +1,18 @@
***************
-*** 866,874 ****
+*** 866,873 ****
\def\tikzexternaldepext{dep}
\def\tikzexternalmakefiledefaultdeprule{%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
-- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}%
- \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
}%
% Invokes '#1' if a makefile is to be written and '#2' if not.
---- 911,919 ----
+--- 911,918 ----
\def\tikzexternaldepext{dep}
\def\tikzexternalmakefiledefaultdeprule{%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
-+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}%
+ \immediate\writetikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}%
}%
diff --git a/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex b/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex
index 1043825..cd99879 100644
--- a/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex
+++ b/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex
@@ -349,12 +349,12 @@
\multiply\c@pgf@countd by60
\c@pgf@countc=\time
\advance\c@pgf@countc by-\c@pgf@countd
- \immediate\openout\w@pgf@writea=\jobname.profiler.\the\year-\pgfprofiletotwodigitstr\month-\pgfprofiletotwodigitstr\day_\pgfprofiletotwodigitstr\c@pgf@countb h_\pgfprofiletotwodigitstr\c@pgf@countc m.dat
- \immediate\write\w@pgf@writea{%
+ \immediate\openw@pgf@writea{\jobname.profiler.\the\year-\pgfprofiletotwodigitstr\month-\pgfprofiletotwodigitstr\day_\pgfprofiletotwodigitstr\c@pgf@countb h_\pgfprofiletotwodigitstr\c@pgf@countc m.dat}
+ \immediate\writew@pgf@writea{%
\pgfprofile@percent relative values are measured against the totaltime of `\pgfprofile@rel'.%
}%
\immediate\write16{pgflibraryprofiler: relative values are measured against the totaltime of `\pgfprofile@rel'.}%
- \immediate\write\w@pgf@writea{%
+ \immediate\writew@pgf@writea{%
profilerentry\pgfprofile@TAB
totaltime[s]\pgfprofile@TAB
totaltime[percent]\pgfprofile@TAB
@@ -379,10 +379,10 @@
}{}%
\pgfprofilepostprocess@single{##1}%
}%
- \immediate\write\w@pgf@writea{%
+ \immediate\writew@pgf@writea{%
\pgfprofile@percent\space vim: ts=40 nowrap nostartofline
}%
- \immediate\closeout\w@pgf@writea
+ \immediate\closew@pgf@writea
\endgroup
}%
@@ -419,7 +419,7 @@
invocations=\csname c@pgfprofile@numinvocations@#1\endcsname;
\pgfprofile@rbrace
}%
- \immediate\write\w@pgf@writea{%
+ \immediate\writew@pgf@writea{%
#1\pgfprofile@TAB
\pgfprofilecur@total\pgfprofile@TAB
\pgfprofilecur@total@rel\pgfprofile@TAB
diff --git a/tex/generic/pgf/modules/pgfmoduleplot.code.tex b/tex/generic/pgf/modules/pgfmoduleplot.code.tex
index ea55ca8..09c99c2 100644
--- a/tex/generic/pgf/modules/pgfmoduleplot.code.tex
+++ b/tex/generic/pgf/modules/pgfmoduleplot.code.tex
@@ -311,7 +311,7 @@
\xdef\pgf@gnuplot@head{set table \noexpand\pgf@plottablefile@quoted; set format "%.5f"}
}
-\let\pgf@plotwrite=\w@pgf@writea
+% \let\pgf@plotwrite=\w@pgf@writea
\newif\ifpgf@resample@plot
\def\pgfplotgnuplot{\pgfutil@ifnextchar[{\pgf@plotgnuplot}{\pgf@plotgnuplot[\jobname]}}%}
diff --git a/tex/generic/pgf/systemlayer/pgfsys.code.tex b/tex/generic/pgf/systemlayer/pgfsys.code.tex
index 3cd39c4..ee8a73e 100644
--- a/tex/generic/pgf/systemlayer/pgfsys.code.tex
+++ b/tex/generic/pgf/systemlayer/pgfsys.code.tex
@@ -56,7 +56,24 @@
\newdimen\pgf@xc
\newdimen\pgf@yc
-\newwrite\w@pgf@writea
+
+\newcommand\openw@pgf@writea[1]{\directlua{
+ if not w_pgf_writea == nil then
+ w_pgf_writea:close()
+ end
+
+ w_pgf_writea = io.open("\luaescapestring{#1}", "w")
+}}
+
+\newcommand\closew@pgf@writea{\directlua{
+ if not w_pgf_writea == nil then
+ w_pgf_writea:close()
+ end
+}}
+
+\newcommand\writew@pgf@writea[1]{\directlua{w_pgf_writea:write("\luaescapestring{#1}\string\n")}}
+%\newwrite\w@pgf@writea
+
\newread\r@pgf@reada
\let\pgfutil@inputcheck=\r@pgf@reada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.