diff options
author | Karl Berry <karl@freefriends.org> | 2014-02-27 00:01:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-02-27 00:01:50 +0000 |
commit | 90ae413a94da014dbf7a6a8ab584f7c668483a5a (patch) | |
tree | 4e0528a2b2fb2004988e7fc804ea2f1354f1f5d5 /Master/texmf-dist/tex/generic/pgf/utilities | |
parent | 800cc56380d1edfe567a6a66bef13e8950eb2b0c (diff) |
pgf 3.0.0
git-svn-id: svn://tug.org/texlive/trunk@33057 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/utilities')
9 files changed, 773 insertions, 316 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex index d31ddedfe26..e984ca06315 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex @@ -7,17 +7,23 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/utilities/pgffor.code.tex,v 1.18 2010/03/23 14:47:45 vibrovski Exp $ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/utilities/pgffor.code.tex,v 1.25 2013/12/13 11:40:27 tantau Exp $ +% pgfmath is needed +\input pgfmath.code.tex \newdimen\pgffor@iter \newdimen\pgffor@skip \newif\ifpgffor@continue -\let\pgffor@beginhook=\pgfutil@empty -\let\pgffor@endhook=\pgfutil@empty -\let\pgffor@afterhook=\pgfutil@empty +\def\pgffor@reset@hooks{% + \let\pgffor@beginhook=\relax% + \let\pgffor@endhook=\relax% + \let\pgffor@afterhook=\relax% +} +\pgffor@reset@hooks + % Stack emulation % @@ -133,20 +139,20 @@ } \def\pgffor@iterate{% - % Must do all of these in case the internal stack is used. - \let\pgffor@last=\pgfutil@empty% + % Must do all of these in case the internal stack is used. + \let\pgffor@last=\pgfutil@empty% \let\pgffor@prevlast=\pgfutil@empty% \let\pgffor@dotsend=\pgfutil@empty% - \let\pgffor@dots@pre=\pgfutil@empty% - \let\pgffor@dots@post=\pgfutil@empty% - % - \expandafter\pgffor@scan\pgffor@values} + \let\pgffor@dots@pre=\pgfutil@empty% + \let\pgffor@dots@post=\pgfutil@empty% + % + \expandafter\pgffor@scan\pgffor@values} \def\pgffor@stop{\pgffor@stop}% \def\pgffor@dots{...}% \def\pgffor@scan{\pgfutil@ifnextchar({\pgffor@scanround}{\pgffor@scanone}} -\def\pgffor@scanround(#1)#2,{\def\pgffor@value{(#1)}\pgffor@scanned} +\def\pgffor@scanround(#1)#2,{\def\pgffor@value{(#1)#2}\pgffor@scanned} \def\pgffor@scanone#1,{\def\pgffor@value{#1}\pgffor@scanned} @@ -215,7 +221,7 @@ \pgffor@assign@before@code% \fi% % - \expandafter\pgffor@beginhook\pgffor@body\pgffor@endhook% + \expandafter\expandafter\expandafter\pgffor@reset@hooks\expandafter\pgffor@beginhook\expandafter\pgffor@body\pgffor@endhook% % Execute assign after code. \ifx\pgffor@assign@after@code\pgfutil@empty% \else% @@ -373,7 +379,7 @@ \pgffor@assign@before@code% \fi% % - \expandafter\pgffor@beginhook\pgffor@body\pgffor@endhook% + \expandafter\expandafter\expandafter\pgffor@reset@hooks\expandafter\pgffor@beginhook\expandafter\pgffor@body\pgffor@endhook% % % Perform assignments after loop body. \ifx\pgffor@assign@after@code\pgfutil@empty% @@ -448,23 +454,21 @@ % Convert the number in the macro passed as #1 to a-z or A-Z. \pgfutil@tempcnta=#1\relax% \ifnum\pgfutil@tempcnta>95\relax% - \advance\pgfutil@tempcnta by-96% - \expandafter\def\expandafter#1\expandafter% - {\pgffor@alpha\pgfutil@tempcnta}% + \advance\pgfutil@tempcnta by-96\relax% + \edef#1{\pgffor@alpha\pgfutil@tempcnta}% \else% - \advance\pgfutil@tempcnta by-64% - \expandafter\def\expandafter#1\expandafter% - {\pgffor@Alpha\pgfutil@tempcnta}% + \advance\pgfutil@tempcnta by-64 % + \edef#1{\pgffor@Alpha\pgfutil@tempcnta}% \fi% } \def\pgffor@Alpha#1{% - \ifcase#1\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M% + \ifcase#1\relax\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M% \or N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else?\fi% } \def\pgffor@alpha#1{% - \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m% + \ifcase#1\relax\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m% \or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else?\fi% } @@ -482,12 +486,12 @@ \begingroup% \escapechar=-1\relax% \expandafter\pgffor@@addiftotoks\string#1\pgffor@stop} -\def\pgffor@@addiftotoks#1#2#3#4#5\pgffor@stop{% +\def\pgffor@@addiftotoks#1#2#3#4\pgffor@stop{% \endgroup - \csname if#4#5\endcsname% - \expandafter\def\expandafter\pgffor@tokstemp\expandafter{\csname#4#5true\endcsname}% + \csname if#3#4\endcsname% + \expandafter\def\expandafter\pgffor@tokstemp\expandafter{\csname#3#4true\endcsname}% \else% - \expandafter\def\expandafter\pgffor@tokstemp\expandafter{\csname#4#5false\endcsname}% + \expandafter\def\expandafter\pgffor@tokstemp\expandafter{\csname#3#4false\endcsname}% \fi% \pgffor@@addcstotoks% } @@ -520,28 +524,32 @@ \let\pgffor@remember@expanded=\pgfutil@empty \def\pgffor@default@endgroup{% - \ifx\pgffor@assign@once@code\pgfutil@empty% - \else% - \global\edef\pgffor@remember@once@expanded{\pgffor@remember@once@code}% - \fi% - \ifx\pgffor@remember@code\pgfutil@empty% - \else% - \global\edef\pgffor@remember@expanded{\pgffor@remember@code}% - \fi% - \endgroup% - % - \ifx\pgffor@remember@once@expanded\pgfutil@empty% - \else% - \pgffor@remember@once@expanded% - \let\pgffor@assign@once@code=\pgfutil@empty% - \global\let\pgffor@remember@once@expanded=\pgfutil@empty% - \fi% - % - \ifx\pgffor@remember@expanded\pgfutil@empty% - \else% - \pgffor@remember@expanded% - \global\let\pgffor@remember@expanded=\pgfutil@empty% - \fi% + \ifx\pgffor@remember@once@code\pgfutil@empty + \else + \xdef\pgffor@remember@once@expanded{\pgffor@remember@once@code}% + \fi + \ifx\pgffor@remember@code\pgfutil@empty + \else + \xdef\pgffor@remember@expanded{\pgffor@remember@code}% + \fi + \endgroup + % + \ifx\pgffor@remember@once@expanded\pgfutil@empty + \else + \pgffor@remember@once@expanded% + % \let\pgffor@assign@once@code=\pgfutil@empty % Not needed anymore? (CJ) + \global\let\pgffor@remember@once@expanded=\pgfutil@empty + \fi + \ifx\pgffor@assign@once@code\pgfutil@empty + \else + \global\let\pgffor@assign@once@code=\pgfutil@empty + \fi + % + \ifx\pgffor@remember@expanded\pgfutil@empty + \else + \pgffor@remember@expanded% + \global\let\pgffor@remember@expanded=\pgfutil@empty + \fi } \let\pgffor@begingroup=\pgffor@default@begingroup diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex index 86e0499ded7..3d79735459d 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex @@ -25,8 +25,14 @@ % This is useful: +\newif\ifpgfkeys@csname@test% + +\def\pgfkeys@ifcsname#1\endcsname#2\else#3\fi{% + \pgfkeys@csname@testfalse% + \expandafter\ifx\csname#1\endcsname\relax\else\expandafter\ifx\csname#1\endcsname\@undefined\else\pgfkeys@csname@testtrue\fi\fi% + \ifpgfkeys@csname@test#2\else#3\fi% +}% -\def\pgfkeys@ifcsname#1\endcsname#2\else#3\fi{\expandafter\ifx\csname#1\endcsname\relax#3\else#2\fi}% \ifx\eTeXrevision\undefined% \else% \expandafter\let\expandafter\pgfkeys@ifcsname\csname ifcsname\endcsname% @@ -37,7 +43,7 @@ % This also: \ifx\PackageError\undefined - \def\pgfkeys@error#1{\immediate\write-1{Package pgfkeys: Error! #1.}}% + \def\pgfkeys@error#1{\errmessage{Package pgfkeys Error: #1.}}% \else \def\pgfkeys@error#1{\PackageError{pgfkeys}{#1}{}}% \fi @@ -180,10 +186,10 @@ % for handled keys). \long\def\pgfkeysifassignable#1#2#3{% \pgfkeysifdefined{#1}% - {#2} - {\pgfkeysifdefined{#1/.@cmd}% - {#2}% - {#3}}% + {#2} + {\pgfkeysifdefined{#1/.@cmd}% + {#2}% + {#3}}% }% @@ -286,14 +292,37 @@ \expandafter\pgfkeys@normal% \fi% } -\long\def\pgfkeys@normal#1,{% +\newif\ifpgfkeys@syntax@handlers +\def\pgfkeys@normal{% + \ifpgfkeys@syntax@handlers% + \expandafter\pgfkeys@syntax@handlers% + \else% + \expandafter\pgfkeys@@normal% + \fi% +} +\def\pgfkeys@syntax@handlers{\pgf@keys@utilifnextchar\relax\pgfkeys@syntax@@handlers\pgfkeys@syntax@@handlers}%get rid of spaces +\def\pgfkeys@syntax@@handlers{\futurelet\pgfkeys@first@char\pgfkeys@syntax@handlers@test} +\def\pgfkeys@syntax@handlers@test{% + \pgfkeysgetvalue{/handlers/first char syntax/\meaning\pgfkeys@first@char}\pgfkeys@the@handler% + \ifx\pgfkeys@the@handler\relax% + \expandafter\pgfkeys@@normal% + \else% + \expandafter\pgfkeys@use@handler% + \fi% +} +\long\def\pgfkeys@use@handler#1,{% + \pgfkeys@the@handler{#1}% + \pgfkeys@parse% +} + +\long\def\pgfkeys@@normal#1,{% \pgfkeys@unpack#1=\pgfkeysnovalue=\pgfkeys@stop% \pgfkeys@parse% } \def\pgfkeys@cleanup\pgfkeys@mainstop{} \def\pgfkeys@mainstop{\pgfkeys@mainstop} % equals only itself -\def\pgfkeys@novalue{} % equals only itself +\def\pgfkeys@novalue{} \def\pgfkeysnovalue{\pgfkeys@novalue} % equals only itself \def\pgfkeysnovalue@text{\pgfkeysnovalue} \def\pgfkeysvaluerequired{\pgfkeysvaluerequired} % equals only itself @@ -312,7 +341,8 @@ {}% no default, so leave it \fi% \ifx\pgfkeyscurrentvalue\pgfkeysvaluerequired% - \pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% + \def\pgf@marshal{\pgfkeysvalueof{/errors/value required/.@cmd}}% + \expandafter\pgf@marshal\expandafter{\pgfkeyscurrentkey}{}\pgfeov% \else% \pgfkeys@case@one% \fi% @@ -356,30 +386,30 @@ \pgfkeys@split@path% \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% \pgfkeys@ifexecutehandler{% - \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov - }{% + }{% % this here is necessary: /my search path/key/.code % won't be called, so \pgfkeyscurrentpath == '/my search path/key' % -> it should be one directory higher! We want to invoke the - % .unknown handler in - % '/my search path' - % - % Idea: - % set - % - path := '/my search path' - % - name := 'key/.code' - % - key = '/my search path/key/.code' - \let\pgfkeys@temp=\pgfkeyscurrentkey - \let\pgfkeys@tempb=\pgfkeyscurrentname + % .unknown handler in + % '/my search path' + % + % Idea: + % set + % - path := '/my search path' + % - name := 'key/.code' + % - key = '/my search path/key/.code' + \let\pgfkeys@temp=\pgfkeyscurrentkey + \let\pgfkeys@tempb=\pgfkeyscurrentname \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% \pgfkeys@split@path% - \let\pgfkeyscurrentkey=\pgfkeys@temp - \edef\pgfkeyscurrentname{\pgfkeyscurrentname/\pgfkeys@tempb}% - \pgfkeys@unknown - }% + \let\pgfkeyscurrentkey=\pgfkeys@temp + \edef\pgfkeyscurrentname{\pgfkeyscurrentname/\pgfkeys@tempb}% + \pgfkeys@unknown + }% }{% - \pgfkeys@unknown + \pgfkeys@unknown }% } @@ -394,37 +424,31 @@ \else % implement the 'only existing' feature here: \pgfkeysifdefined{\pgfkeyscurrentpath}{#1}{% - \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{#1}{#2}% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{#1}{#2}% }{}% \fi% }% \def\pgfkeys@ifexecutehandler@handlefullorexisting#1#2{% \ifpgfkeysaddeddefaultpath \pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% -%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentname' is an exception; processing it (on \pgfkeyscurrentpath).}% #1% ok, this particular key handler is known and be processed in any case (for example .try) \else % implement the 'only existing' feature here: \pgfkeysifdefined{\pgfkeyscurrentpath}{% -%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does exist. Executing '\pgfkeyscurrentname'.}% - #1% - }{% - \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{% -%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath/.@cmd' does exist. Executing '\pgfkeyscurrentname'.}% - #1% - }{% -%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does NOT exist. Skipping '\pgfkeyscurrentname'.}% - #2% - }% - }% + #1% + }{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{% + #1% + }{% + #2% + }% + }% \fi% \else -%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): Fully qualified key provided. Executing '\pgfkeyscurrentname'.}% #1% ok, always true if the USER explicitly provided the full key path. \fi }% -\def\pgfkeysaddhandlyonlyexistingexception#1{\expandafter\def\csname pgfk@excpt@#1\endcsname{1}}% - +\def\pgfkeysaddhandleonlyexistingexception#1{\expandafter\def\csname pgfk@excpt@#1\endcsname{1}}% \def\pgfkeys@unknown{% \pgfkeysifdefined{\pgfkeyscurrentpath/.unknown/.@cmd}% @@ -579,10 +603,12 @@ \long\def\pgfkeysdef#1#2{% \long\def\pgfkeys@temp##1\pgfeov{#2}% \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% + \pgfkeyssetvalue{#1/.@body}{#2}% } \long\def\pgfkeysedef#1#2{% \long\edef\pgfkeys@temp##1\pgfeov{#2}% \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% + \pgfkeyssetvalue{#1/.@body}{#2}% } @@ -628,27 +654,27 @@ % % defnargs: % \pgfkeysdefnargs{/a}{2}{1=`#1', 2=`#2'} % \pgfkeys{ -% /a= -% {1} -% {2} +% /a= +% {1} +% {2} % } % ->defnargs: 1=`1', 2=`2' % % defargs: % \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'} % \pgfkeys{ -% /b= -% {1} -% {2} +% /b= +% {1} +% {2} % } % ->defargs: 1=`1', 2=` 2' (note the space!) % % defargs: % \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'} % \pgfkeys{ -% /b= -% {1}% -% {2} +% /b= +% {1}% +% {2} % } % ->defargs: 1=`1', 2=`2' %-------------------------------------------------- @@ -656,32 +682,30 @@ \long\def\pgfkeysedefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\edef}}% \long\def\pgfkeysdefnargs@#1#2#3#4{% \ifcase#2\relax - \pgfkeyssetvalue{#1/.@args}{}% + \pgfkeyssetvalue{#1/.@args}{}% \or - \pgfkeyssetvalue{#1/.@args}{##1}% + \pgfkeyssetvalue{#1/.@args}{##1}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2}% + \pgfkeyssetvalue{#1/.@args}{##1##2}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8}% \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8}% - \or - \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8##9}% + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8##9}% \else - \pgfkeys@error{\string\pgfkeysdefnargs: expected <= 9 arguments, got #2}% + \pgfkeys@error{\string\pgfkeysdefnargs: expected <= 9 arguments, got #2}% \fi \pgfkeysgetvalue{#1/.@args}\pgfkeys@tempargs - \def\pgfkeys@temp{\expandafter#4\csname pgfk@#1/.@@body\endcsname}% + \def\pgfkeys@temp{\expandafter\long\expandafter#4\csname pgfk@#1/.@@body\endcsname}% \expandafter\pgfkeys@temp\pgfkeys@tempargs{#3}% % eliminate the \pgfeov at the end such that TeX gobbles spaces % by using @@ -712,34 +736,37 @@ % Find out, whether with args or not. \pgfkeysifdefined{\pgfkeyscurrentpath/.@args}% {% Yes, so add to body and reuse args - \pgfkeysaddvalue{\pgfkeyscurrentpath/.@body}{#1}{#2}% - % Redefine code - {% - \pgfkeysgetvalue{\pgfkeyscurrentpath/.@args}{\pgfkeys@tempargs}% - \pgfkeysgetvalue{\pgfkeyscurrentpath/.@body}{\pgfkeys@tempbody}% - \def\pgfkeys@marshal{\expandafter\gdef\expandafter\pgfkeys@global@temp\pgfkeys@tempargs}% - \expandafter\pgfkeys@marshal\expandafter{\pgfkeys@tempbody}% - }% + \pgfkeysaddvalue{\pgfkeyscurrentpath/.@body}{#1}{#2}% + % Redefine code + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@args}{\pgfkeys@tempargs}% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@body}{\pgfkeys@tempbody}% + \def\pgfkeys@marshal{\expandafter\gdef\expandafter\pgfkeys@global@temp\pgfkeys@tempargs}% + \expandafter\pgfkeys@marshal\expandafter{\pgfkeys@tempbody}% + }% \pgfkeysifdefined{\pgfkeyscurrentpath/.@@body}{% - % support for \pgfkeysndefargs: - \pgfkeyslet{\pgfkeyscurrentpath/.@@body}{\pgfkeys@global@temp}% - }{% - % support for \pgfkeysdefargs: + % support for \pgfkeysndefargs: + \pgfkeyslet{\pgfkeyscurrentpath/.@@body}{\pgfkeys@global@temp}% + }{% + % support for \pgfkeysdefargs: \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@global@temp}% - }% + }% }% {% % No, so single argument (simple \pgfkeysdef). Redefine accordingly. + \edef\pgf@expanded@path{\pgfkeyscurrentpath}% {% \toks0{#1}% - \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% - {\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname##1\pgfeov}}% - {\pgfkeys@temptoks{}}% + \pgfkeysifdefined{\pgf@expanded@path/.@cmd}% + {\expandafter\expandafter\expandafter\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@\pgf@expanded@path/.@body\endcsname}}% + {\expandafter\pgfkeys@temptoks\expandafter{\expandafter\pgfkeyssetvalue\expandafter{\pgf@expanded@path}{##1}}}% \toks1{#2}% \xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1 }% }% - \expandafter\def\expandafter\pgfkeys@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% - \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}\pgfkeys@temp% + \def\pgf@temp{\pgfkeyssetvalue{\pgf@expanded@path/.@body}}% + \expandafter\pgf@temp\expandafter{\pgfkeys@global@temp}% + \expandafter\long\expandafter\def\expandafter\pgfkeys@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + \pgfkeyslet{\pgf@expanded@path/.@cmd}\pgfkeys@temp% }% } \pgfkeys{/handlers/.prefix code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={#1}{}}}% @@ -780,7 +807,8 @@ {% \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% \else% - \pgfkeysvalueof{/errors/value forbidden/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% + \def\pgf@marshal{\pgfkeysvalueof{/errors/value forbidden/.@cmd}}% + \expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\pgfkeyscurrentkey\expandafter}\expandafter{\pgfkeyscurrentvalue}\pgfeov% \fi% }{}}} @@ -799,23 +827,32 @@ \pgfkeys@ifcsname#1#2\endcsname% \csname#1#2\endcsname% \else% - \pgfkeysvalueof{/errors/boolean expected/.@cmd}\pgfkeyscurrentkey{#2}\pgfeov% + \def\pgf@marshal{\pgfkeysvalueof{/errors/boolean expected/.@cmd}}% + \expandafter\pgf@marshal\expandafter{\pgfkeyscurrentkey}{#2}\pgfeov% \fi } \pgfkeys{/handlers/.is choice/.code=% \pgfkeys{% \pgfkeyscurrentpath/.cd,% - .code=\expandafter\pgfkeysalso\expandafter{\pgfkeyscurrentkey/##1}, - .unknown/.style={/errors/unknown choice value=\pgfkeyscurrentkey\pgfkeyscurrentvalue}}} + .code=\def\pgfkeys@was@choice{##1}\expandafter\pgfkeysalso\expandafter{\pgfkeyscurrentkey/##1}, + .unknown/.code={% + \def\pgf@marshal{\pgfkeysvalueof{/errors/unknown choice value/.@cmd}}% + {\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@pathtoks\expandafter}\expandafter{\pgfkeys@was@choice}\pgfeov}% + }% + }% +} % Repeatedly setting a key \pgfkeys{/handlers/.list/.code=% {% + \ifx\foreach\@undefined% + \pgfkeys@error{You need to load the pgffor package to use the .list key syntax.}% + \fi% % Use foreach to unfold the list - \let\pgf@keys@temp=\pgfutil@empty% + \def\pgf@keys@temp{}% \foreach \pgf@keys@key in{#1}% {\expandafter\expandafter\expandafter\gdef% \expandafter\expandafter\expandafter\pgf@keys@temp% @@ -825,10 +862,16 @@ \expandafter\expandafter\expandafter{\expandafter\pgf@keys@list@path\expandafter}\pgf@keys@temp\pgf@stop% }% } -\def\pgf@keys@do@list#1{\pgfutil@ifnextchar\bgroup{\pgf@keys@do@list@item{#1}}\pgfutil@gobble} +\def\pgf@keys@do@list#1{\pgf@keys@utilifnextchar\bgroup{\pgf@keys@do@list@item{#1}}\pgf@keys@gobble} \def\pgf@keys@do@list@item#1#2{\pgfkeysalso{#1={#2}}\pgf@keys@do@list{#1}} +% Forwarding + +\pgfkeys{/handlers/.forward to/.code=% + \pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeys{#1={##1}}}} +} + % Inspection handlers @@ -836,6 +879,9 @@ \pgfkeys{/handlers/.show code/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeysshower}\show\pgfkeysshower} % inspect the body of the command +% First char syntax handlers +\pgfkeys{/handlers/first char syntax/.is if=pgfkeys@syntax@handlers} + % Path handling % Prepares the .unknown handler used by '.search also'. @@ -844,22 +890,23 @@ \global\def\pgfkeys@global@temp##1\pgfeov{}% \pgfkeys@searchalso@parse#1,\pgfkeys@mainstop {% - \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% - \toks1={\def\pgfutilnext{\pgfkeysvalueof{/handlers/.unknown/.@cmd}##1\pgfeov}\pgfutilnext}% - \xdef\pgfkeys@global@temp{% - \noexpand\ifpgfkeysaddeddefaultpath - \noexpand\pgfkeyssuccessfalse - \noexpand\let\noexpand\pgfkeys@searchalso@name=\noexpand\pgfkeyscurrentkeyRAW - \the\toks0 % one or more /.try things; one for each path. The last element won't have a /.try - %\noexpand\ifpgfkeyssuccess - %\noexpand\else - % \the\toks1 % invoke /handlers/.unknown handler - %\noexpand\fi - \noexpand\else - \the\toks1 % invoke /handlers/.unknown handler - \noexpand\fi - }% - \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% + \toks1={\pgfkeysalso{/handlers/.unknown/.@cmd/.expand once=\pgfkeys@searchalso@temp@value}}% + \xdef\pgfkeys@global@temp{% + \noexpand\def\noexpand\pgfkeys@searchalso@temp@value{####1}% + \noexpand\ifpgfkeysaddeddefaultpath + \noexpand\pgfkeyssuccessfalse + \noexpand\let\noexpand\pgfkeys@searchalso@name=\noexpand\pgfkeyscurrentkeyRAW + \the\toks0 % one or more /.try things; one for each path. The last element won't have a /.try + %\noexpand\ifpgfkeyssuccess + %\noexpand\else + % \the\toks1 % invoke /handlers/.unknown handler + %\noexpand\fi + \noexpand\else + \the\toks1 % invoke /handlers/.unknown handler + \noexpand\fi + }% + \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% }% }% @@ -876,36 +923,36 @@ \pgfkeys@spdef\pgfkeys@temp{#1}% {% \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% - \toks1=\expandafter{\pgfkeys@temp}% - \toks2={##1}% - \xdef\pgfkeys@global@temp{% - \the\toks0 % the space is important! - \noexpand\ifpgfkeyssuccess\noexpand\else - \noexpand\pgfqkeys{\the\toks1 }{\noexpand\pgfkeys@searchalso@name - \ifx\pgfkeys@searchalso@nexttok\pgfkeys@mainstop\else/.try\fi={\the\toks2 }}% - \noexpand\fi}% - \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + \toks1=\expandafter{\pgfkeys@temp}% + \xdef\pgfkeys@global@temp{% + \the\toks0 % the space is important! + \noexpand\ifpgfkeyssuccess\noexpand\else + \noexpand\pgfqkeys{\the\toks1 }{\noexpand\pgfkeys@searchalso@name + \ifx\pgfkeys@searchalso@nexttok\pgfkeys@mainstop\else/.try\fi /.expand once=\noexpand\pgfkeys@searchalso@temp@value}% + \noexpand\fi}% + \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% }% \pgfkeys@searchalso@parse#2% } \pgfkeys{% - /handlers/.is family/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\edef\noexpand\pgfkeysdefaultpath{\pgfkeyscurrentpath/}},% - /handlers/.cd/.code=\edef\pgfkeysdefaultpath{\pgfkeyscurrentpath/},% - /handlers/.search also/.code={% - \pgfkeys@searchalso@prepare@unknown@handler{#1}% + /handlers/.is family/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\edef\noexpand\pgfkeysdefaultpath{\pgfkeyscurrentpath/}},% + /handlers/.cd/.code=\edef\pgfkeysdefaultpath{\pgfkeyscurrentpath/},% + /handlers/.search also/.code={% + \pgfkeys@searchalso@prepare@unknown@handler{#1}% %\message{I prepared the '\pgfkeyscurrentpath/.unknown' handler \meaning\pgfkeys@global@temp\space for '#1'.}% - \pgfkeyslet{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@global@temp}% - } + \pgfkeyslet{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@global@temp}% + } }% % Value expansion \pgfkeys{/handlers/.expand once/.code=\expandafter\pgfkeys@exp@call\expandafter{#1}} +\pgfkeys{/handlers/.expand two once/.code 2 args=\expandafter\expandafter\expandafter\pgfkeys@exp@call\expandafter\expandafter\expandafter{\expandafter#1\expandafter}\expandafter{#2}} \pgfkeys{/handlers/.expand twice/.code=\expandafter\expandafter\expandafter\pgfkeys@exp@call\expandafter\expandafter\expandafter{#1}} \pgfkeys{/handlers/.expanded/.code=\edef\pgfkeys@temp{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfkeys@temp}} -\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} +\long\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} % Try to set a key and do nothing if not define @@ -938,20 +985,20 @@ {% \pgfkeys@split@path% \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% - % in the standard configuration, this check here is redundand - % because pgfkeys@ifexecutehandler === true. - % It is only interesting for 'handle only existing'. + % in the standard configuration, this check here is redundand + % because pgfkeys@ifexecutehandler === true. + % It is only interesting for 'handle only existing'. \pgfkeys@ifexecutehandler{% - \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov \pgfkeyssuccesstrue% - }{% - \pgfkeyssuccessfalse - }% }{% - \pgfkeyssuccessfalse + \pgfkeyssuccessfalse }% - }% + }{% + \pgfkeyssuccessfalse + }% + }% }% } @@ -962,49 +1009,111 @@ % Errors -\pgfkeys{/errors/boolean expected/.code 2 args=\pgfkeys@error{% - Boolean parameter of key '#1' must be 'true' or 'false', not - '#2'. I am going to ignore it}} -\pgfkeys{/errors/value required/.code 2 args=\pgfkeys@error{% - The key '#1' requires a value. I am going to ignore this key}{}} -\pgfkeys{/errors/value forbidden/.code 2 args=\pgfkeys@error{% - You may not specify a value for the key '#1'. I am going to ignore - the value '#2' that you provided}} -\pgfkeys{/errors/unknown choice value/.code 2 args=\pgfkeys@error{% - Choice '\pgfkeyscurrentname' unknown in key - '\pgfkeyscurrentpath'. I am going to ignore this key}} -\pgfkeys{/errors/unknown key/.code 2 args=\pgfkeys@error{% - I do not know the key '#1' and I am going to ignore it. Perhaps - you misspelled it}} +\pgfkeys{ + /errors/boolean expected/.code 2 args=% + { + \toks1={#1} + \toks2={#2} + \pgfkeys@error{% + Boolean parameter of key '\the\toks1' must be 'true' or 'false', not + '\the\toks2'. I am going to ignore it% + } + }, + /errors/value required/.code 2 args=% + { + \toks1={#1} + \pgfkeys@error{% + The key '\the\toks1' requires a value. I am going to ignore this + key% + } + }, + /errors/value forbidden/.code 2 args=% + { + \toks1={#1} + \toks2={#2} + \pgfkeys@error{% + You may not specify a value for the key '\the\toks1'. I am going to ignore + the value '\the\toks2' that you provided% + } + }, + /errors/unknown choice value/.code 2 args=% + { + \toks1={#1} + \toks2={#2} + \pgfkeys@error{% + Choice '\the\toks2' unknown in choice key '\the\toks1'. I am + going to ignore this key% + } + }, + /errors/unknown key/.code 2 args=% + { + \toks1={#1} + \toks2={#2} + \def\pgf@temp{#2}% + \pgfkeys@error{% + I do not know the key '\the\toks1'\ifx\pgf@temp\pgfkeysnovalue@text\space\else, to which you passed + '\the\toks2', \fi and I am going to ignore it. Perhaps you + misspelled it% + } + } +} \pgfkeys{/handlers/.unknown/.code=% {% - \let\pgfkeys@orig@key=\pgfkeyscurrentkey% - \pgfkeysalso{/errors/unknown key=\pgfkeys@orig@key{}}% - } + \def\pgf@marshal{\pgfkeysvalueof{/errors/unknown key/.@cmd}}% + {\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\pgfkeyscurrentkey\expandafter}\expandafter{\pgfkeyscurrentvalue}\pgfeov}% + }% } \pgfkeys{ - /handler config/.is choice, - /handler config/all/.code={% - \let\pgfkeys@case@three=\pgfkeys@case@three@handleall - \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleall - }, - /handler config/only existing/.code={% - \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted - \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleonlyexisting - }, - /handler config/full or existing/.code={% - \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted - \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handlefullorexisting - }, - /handler config/only existing/add exception/.code={\pgfkeysaddhandlyonlyexistingexception{#1}}, + /handler config/.is choice, + /handler config/all/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handleall + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleall + }, + /handler config/only existing/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleonlyexisting + }, + /handler config/full or existing/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handlefullorexisting + }, + /handler config/only existing/add exception/.code={\pgfkeysaddhandleonlyexistingexception{#1}}, }% -\pgfkeysaddhandlyonlyexistingexception{.cd}% -\pgfkeysaddhandlyonlyexistingexception{.try}% -\pgfkeysaddhandlyonlyexistingexception{.retry}% -\pgfkeysaddhandlyonlyexistingexception{.lastretry}% -\pgfkeysaddhandlyonlyexistingexception{.unknown}% +\pgfkeysaddhandleonlyexistingexception{.cd}% +\pgfkeysaddhandleonlyexistingexception{.try}% +\pgfkeysaddhandleonlyexistingexception{.retry}% +\pgfkeysaddhandleonlyexistingexception{.lastretry}% +\pgfkeysaddhandleonlyexistingexception{.unknown}% +\pgfkeysaddhandleonlyexistingexception{.expand once}% +\pgfkeysaddhandleonlyexistingexception{.expand two once}% +\pgfkeysaddhandleonlyexistingexception{.expand twice}% +\pgfkeysaddhandleonlyexistingexception{.expanded}% + + +% Utilities for self-containment +\def\pgf@keys@gobble#1{} +\long\def\pgf@keys@utilifnextchar#1#2#3{% + \let\pgf@keys@utilreserved@d=#1% + \def\pgf@keys@utilreserved@a{#2}% + \def\pgf@keys@utilreserved@b{#3}% + \futurelet\pgf@keys@utillet@token\pgf@keys@utilifnch} +\def\pgf@keys@utilifnch{% + \ifx\pgf@keys@utillet@token\pgf@keys@utilsptoken + \let\pgf@keys@utilreserved@c\pgf@keys@utilxifnch + \else + \ifx\pgf@keys@utillet@token\pgf@keys@utilreserved@d + \let\pgf@keys@utilreserved@c\pgf@keys@utilreserved@a + \else + \let\pgf@keys@utilreserved@c\pgf@keys@utilreserved@b + \fi + \fi + \pgf@keys@utilreserved@c} +{% + \def\:{\global\let\pgf@keys@utilsptoken= } \: + \def\:{\pgf@keys@utilxifnch} \expandafter\gdef\: {\futurelet\pgf@keys@utillet@token\pgf@keys@utilifnch} +} \input pgfkeysfiltered.code.tex diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex index c46e418ddad..ef7411da924 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex @@ -132,7 +132,7 @@ % #1: old value of default path. % #2: key-value-list. -\def\pgfkeysfiltered@@install#1#2{% +\long\def\pgfkeysfiltered@@install#1#2{% \pgfkeys@install@filter@and@invoke{% \let\pgfkeysdefaultpath\pgfkeys@root% \pgfkeys@parse#2,\pgfkeys@mainstop% @@ -162,7 +162,7 @@ } % #1 = options -\long\long\def\pgfkeysalsofiltered#1{% +\long\def\pgfkeysalsofiltered#1{% \pgfkeys@install@filter@and@invoke{\pgfkeysalso{#1}}% }% @@ -922,7 +922,7 @@ % #1 the code to invoke after init and before cleanup -\def\pgfkeys@install@filter@and@invoke#1{% +\long\def\pgfkeys@install@filter@and@invoke#1{% \ifpgfkeysfilteringisactive \pgfkeys@error{Sorry, nested calls to key filtering routines are not allowed. (reason: It is not possible to properly restore the previous filtering state after returning from the nested call)}% \fi diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex index 6a0a1be016d..4f9d167e7bb 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex @@ -15,10 +15,8 @@ % prints out a message to the log. -%\def\pgfversion{2.00-cvs} -%\def\pgftypesetversion{\oldstylenums{2}.\oldstylenums{00}--\textsc{cvs}} -\def\pgfversion{2.10} -\def\pgftypesetversion{\oldstylenums{2}.\oldstylenums{10}} +\def\pgfversion{3.0.0} +\def\pgftypesetversion{\oldstylenums{3}.\oldstylenums{0}.\oldstylenums{0}} \ifx\pgfrcsloaded\undefined @@ -89,9 +87,13 @@ \def\ProvidesFile#1[#2]{\wlog{Loading file #1 version #2.}} \fi -\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/utilities/pgfrcs.code.tex,v 1.24 2010/10/25 20:57:06 ludewich Exp $ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/utilities/pgfrcs.code.tex,v 1.28 2013/12/20 14:44:47 tantau Exp $ \catcode`\@=\pgfrcsatcode \fi + +% Local Variables: +% coding: undecided-unix +% End: diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.tex new file mode 100644 index 00000000000..26529cd5e37 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.tex @@ -0,0 +1,159 @@ +% Copyright 2013 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% This list here is a general re-implementation of the list used in +% the PGF system layer. +% It employs two collect-buffers to reduce the runtime. +% +% - It has preasymptotical runtime O(N), but is O(N^2) asymptotically. +% - It requires only 5 macros per list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Usage: +% \pgfapplistnewempty\macro +\def\pgfapplistnewempty#1{% + \expandafter\let\csname pgfapp@#1\endcsname=\pgfutil@empty + \expandafter\let\csname pgfapp@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\let\csname pgfapp@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfapp@#1@smallbuf@c\endcsname{0}% + \expandafter\def\csname pgfapp@#1@bigbuf@c\endcsname{0}% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfapplistpushback#1\to#2{% + \begingroup + \c@pgf@counta=\csname pgfapp@#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgf@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfapp@#2@smallbuf@c\endcsname=\pgf@glob@TMPa + \ifnum\csname pgfapp@#2@smallbuf@c\endcsname<40 + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#2@smallbuf\endcsname#1}% + \expandafter\edef\csname pgfapp@#2@smallbuf\endcsname{\the\t@pgf@toka}% + \else + \pgfapplistpushback@smallbufoverfl{#1}{#2}% + \fi +}% +\long\def\pgfapplistpushback@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname pgfapp@#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgf@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfapp@#2@bigbuf@c\endcsname=\pgf@glob@TMPa + % + \ifnum\csname pgfapp@#2@bigbuf@c\endcsname<30 + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#2@bigbuf\endcsname}% + \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfapp@#2@smallbuf\endcsname#1}% + \expandafter\edef\csname pgfapp@#2@bigbuf\endcsname{\the\t@pgf@toka\the\t@pgf@tokb}% + \expandafter\let\csname pgfapp@#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfapp@#2@smallbuf@c\endcsname{0}% + \else% + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#2\endcsname}% + \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfapp@#2@bigbuf\endcsname}% + \t@pgf@tokc=\expandafter\expandafter\expandafter{\csname pgfapp@#2@smallbuf\endcsname#1}% + \expandafter\edef\csname pgfapp@#2\endcsname{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}% + \expandafter\let\csname pgfapp@#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfapp@#2@smallbuf@c\endcsname{0}% + \expandafter\let\csname pgfapp@#2@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfapp@#2@bigbuf@c\endcsname{0}% + \fi% +}% +\def\pgfapplist@flushbuffers#1{% + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#1\endcsname}% + \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfapp@#1@bigbuf\endcsname}% + \t@pgf@tokc=\expandafter\expandafter\expandafter{\csname pgfapp@#1@smallbuf\endcsname}% + \expandafter\edef\csname pgfapp@#1\endcsname{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}% + \expandafter\let\csname pgfapp@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfapp@#1@smallbuf@c\endcsname{0}% + \expandafter\let\csname pgfapp@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfapp@#1@bigbuf@c\endcsname{0}% +}% + +\def\pgfapplistlet#1=#2{% + \pgfapplist@flushbuffers{#2}% + \expandafter\let\expandafter#1\csname pgfapp@#2\endcsname +}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% A variant of applist which has the same runtime requirements, but +% does PUSH FRONT only. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Usage: +% \pgfprependlistnewempty{list} +\def\pgfprependlistnewempty#1{% + \expandafter\let\csname pgfpPRP@#1\endcsname=\pgfutil@empty + \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}% + \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfprependlistpushfront#1\to#2{% + \begingroup + \c@pgf@counta=\csname pgfpPRP@#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgf@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfpPRP@#2@smallbuf@c\endcsname=\pgf@glob@TMPa + \ifnum\csname pgfpPRP@#2@smallbuf@c\endcsname<40 + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}% + \t@pgf@tokb={#1}% + \expandafter\edef\csname pgfpPRP@#2@smallbuf\endcsname{\the\t@pgf@tokb\the\t@pgf@toka}% + \else + \pgfprependlistpushfront@smallbufoverfl{#1}{#2}% + \fi +}% +\long\def\pgfprependlistpushfront@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname pgfpPRP@#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgf@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfpPRP@#2@bigbuf@c\endcsname=\pgf@glob@TMPa + % + \ifnum\csname pgfpPRP@#2@bigbuf@c\endcsname<30 + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@bigbuf\endcsname}% + \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}% + \t@pgf@tokc={#1}% + \expandafter\edef\csname pgfpPRP@#2@bigbuf\endcsname{\the\t@pgf@tokc\the\t@pgf@tokb\the\t@pgf@toka}% + \expandafter\let\csname pgfpPRP@#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#2@smallbuf@c\endcsname{0}% + \else% + \pgfprependlist@flushbuffers{#2}% + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2\endcsname}% + \t@pgf@tokb={#1}% + \expandafter\edef\csname pgfpPRP@#2\endcsname{\the\t@pgf@tokb\the\t@pgf@toka}% + \fi% +}% +\def\pgfprependlist@flushbuffers#1{% + \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1\endcsname}% + \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@bigbuf\endcsname}% + \t@pgf@tokc=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@smallbuf\endcsname}% + \expandafter\edef\csname pgfpPRP@#1\endcsname{\the\t@pgf@tokc\the\t@pgf@tokb\the\t@pgf@toka}% + \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}% + \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}% +}% +\def\pgfprependlistlet#1=#2{% + \pgfprependlist@flushbuffers{#2}% + \expandafter\let\expandafter#1\csname pgfpPRP@#2\endcsname +}% diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex index 7b3c34a0510..cdf0cfe821d 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex @@ -27,17 +27,40 @@ \catcode`\@=11\relax +% Which format is loaded? +\newif\ifpgfutil@format@is@latex +\newif\ifpgfutil@format@is@plain +\newif\ifpgfutil@format@is@context + + % Simple stuff -\long\def\pgfutil@ifundefined#1{% +% \pgfutil@ifundefined{<macro name with backslash>} +% {<is undefined code>}{<is defined code>} +% +% This will let #1 to \relax if it undefined. +% +% This macro is expandable. +\def\pgfutil@ifundefined#1{% \expandafter\ifx\csname#1\endcsname\relax \expandafter\pgfutil@firstoftwo \else \expandafter\pgfutil@secondoftwo \fi} -\def\pgfutil@firstofone#1{#1} -\def\pgfutil@firstoftwo#1#2{#1} -\def\pgfutil@secondoftwo#1#2{#2} + +% A variant of \pgfutil@ifundefined which will NOT let #1 to \relax it +% is undefined. However, this macro is not expandable. +\def\pgfutil@IfUndefined#1{% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname#1\endcsname\relax + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi +} +\long\def\pgfutil@firstofone#1{#1} +\long\def\pgfutil@firstoftwo#1#2{#1} +\long\def\pgfutil@secondoftwo#1#2{#2} \def\pgfutil@empty{} \def\pgfutil@gobble@until@relax#1\relax{} \def\pgfutil@gobble#1{} @@ -51,6 +74,7 @@ \xdef#1{\the\pgfutil@toks@}% \endgroup} \newif\ifpgfutil@tempswa +\newif\ifpgfutil@tempswb % pgfutil@ifnextchar @@ -111,12 +135,13 @@ \expandafter\pgfutil@fornoop \else #4\relax\expandafter\pgfutil@iforloop\fi#2\@@#3{#4}} \def\pgfutil@tfor#1:={\pgfutil@tf@r#1 } -\long\def\pgfutil@tf@r#1#2\do#3{\def\pgfutil@fortmp{#2}\ifx\pgfutil@fortmp\space\else +\long\def\pgfutil@tf@r#1#2\do#3{\def\pgfutil@fortmp{#2}\ifx\pgfutil@fortmp\pgfutil@space\else \pgfutil@tforloop#2\pgfutil@nil\pgfutil@nil\@@#1{#3}\fi} \long\def\pgfutil@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\pgfutil@nnil \expandafter\pgfutil@fornoop \else #4\relax\expandafter\pgfutil@tforloop\fi#2\@@#3{#4}} +\def\pgfutil@space{ } % pgfutil@IfFileExists @@ -170,6 +195,19 @@ \let\pgfutil@insertatbegincurrentpage=\relax +% Ragged left and ragged right + +\def\pgfutil@raggedright{\rightskip\z@ plus2em \spaceskip.3333em \xspaceskip.5em\relax} +\def\pgfutil@raggedleft{\leftskip\z@ plus2em \rightskip\z@ \spaceskip.3333em \xspaceskip.5em\parfillskip0pt\relax} + + +% Error Messages +\def\pgfutil@packageerror#1#2#3{\errhelp{#3}\errmessage{Package #1 Error: #2}} +\def\pgfutil@packagewarning#1#2{\immediate\write17{Package #1: Warning! #2.}} +\def\pgferror#1{\pgfutil@packageerror{pgf}{#1}{}} +\def\pgfwarning#1{\pgfutil@packagewarning{pgf}{#1}} + + % Library files inclusion @@ -196,20 +234,28 @@ \def\use@@pgflibrary#1{% \edef\pgf@list{#1}% \pgfutil@for\pgf@temp:=\pgf@list\do{% - \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% - \ifx\pgf@temp\pgfutil@empty - \else - \expandafter\ifx\csname pgf@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\let\csname pgf@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% - \expandafter\edef\csname pgf@library@#1@atcode\endcsname{\the\catcode`\@} - \expandafter\edef\csname pgf@library@#1@barcode\endcsname{\the\catcode`\|} - \catcode`\@=11 - \catcode`\|=12 - \input pgflibrary\pgf@temp.code.tex - \catcode`\@=\csname pgf@library@#1@atcode\endcsname - \catcode`\|=\csname pgf@library@#1@barcode\endcsname - \fi% - \fi + \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% + \ifx\pgf@temp\pgfutil@empty + \else + \expandafter\ifx\csname pgf@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\let\csname pgf@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname pgf@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname pgf@library@#1@barcode\endcsname{\the\catcode`\|} + \expandafter\edef\csname pgf@library@#1@dollarcode\endcsname{\the\catcode`\$} + \catcode`\@=11 + \catcode`\|=12 + \catcode`\$=3 + \pgfutil@InputIfFileExists{pgflibrary\pgf@temp.code.tex}{}{% + \pgferror{I did not find the pgf library + '\pgf@temp'. I looked for the file named + pgflibrary\pgf@temp.code.tex, but could not find it in in + the current texmf trees.} + }% + \catcode`\@=\csname pgf@library@#1@atcode\endcsname + \catcode`\|=\csname pgf@library@#1@barcode\endcsname + \catcode`\$=\csname pgf@library@#1@dollarcode\endcsname + \fi% + \fi }% } @@ -240,11 +286,14 @@ \expandafter\let\csname pgf@module@\pgf@temp @loaded\endcsname=\pgfutil@empty% \expandafter\edef\csname pgf@module@#1@atcode\endcsname{\the\catcode`\@} \expandafter\edef\csname pgf@module@#1@barcode\endcsname{\the\catcode`\|} + \expandafter\edef\csname pgf@module@#1@dollarcode\endcsname{\the\catcode`\$} \catcode`\@=11 \catcode`\|=12 + \catcode`\$=3 \input pgfmodule\pgf@temp.code.tex \catcode`\@=\csname pgf@module@#1@atcode\endcsname \catcode`\|=\csname pgf@module@#1@barcode\endcsname + \catcode`\$=\csname pgf@module@#1@dollarcode\endcsname \fi% }% } @@ -258,8 +307,6 @@ % Guess the driver: % -\def\pgfutil@guessdriver{\edef\pgfsysdriver{pgfsys-\Gin@driver}} - \begingroup \catcode`\"=12 \edef\pgf@loc@TMPa{"}% @@ -461,4 +508,51 @@ \let\pgfutil@write=\write \let\pgfutil@read=\read +% curtesy for latex: +\let\pgfutil@protect\relax + + +% new tempdims: +\newdimen\pgfutil@tempdima +\newdimen\pgfutil@tempdimb + + +% luatex stuff +% We assume luatex version > 0.39: +% - \directlua <general text> will work +% - \directlua is the only luatex primitive that we can assume +% accessible without being prefixed by the format via +% tex.enableprimitives. +% Ideas taken from the ifluatex package (Heiko Oberdiek) +\let\pgfutil@ifluatex\iffalse +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname directlua\endcsname\relax +\else + \expandafter\let\csname pgfutil@ifluatex\expandafter\endcsname + \csname iftrue\endcsname +\fi + +\pgfutil@ifluatex + \let\pgfutil@directlua\directlua + \pgfutil@directlua{% + tex.enableprimitives('pgfutil@',{'luaescapestring'})} +\else + \def\pgfutil@directlua#1{} + \def\pgfutil@luaescapestring#1{} +\fi +% End of luatex stuff + +% Advances a number stored in a macro and writes the result back into +% the macro. +% #1 is a macro containing a number. +\def\pgfutil@advancestringcounter#1{% + \begingroup + \c@pgf@counta=#1\relax + \advance\c@pgf@counta by1 + \edef#1{\the\c@pgf@counta}% + \pgfmath@smuggleone#1% + \endgroup +}% +\input pgfutil-common-lists.tex + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def index 202778f5802..22c2a291417 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def @@ -1,4 +1,4 @@ -% Copyright 2006, 2011 by Till Tantau +% Copyright 2006 by Till Tantau % % This file may be distributed and/or modified % @@ -8,6 +8,7 @@ % See the file doc/generic/pgf/licenses/LICENSE for more details. +\pgfutil@format@is@contexttrue % The aux files, needed for reading back coordinates @@ -16,6 +17,7 @@ \csname newwrite\endcsname\pgfutil@auxout \csname openout\endcsname\pgfutil@auxout\jobname.pgf } +\def\pgfutil@writetoaux#1{\write\pgfutil@auxout{#1}} % XColor-like support for ConTeXt @@ -138,23 +140,30 @@ \def\pgfutil@emu@select#1#2#3#4#5{#5} - +% The cmyk part is from Joseph Wright. +% See tex.stackexchange.com/questions/27952/cmyk-context-colors-in-tikz \def\pgfutil@registercolor#1{% \edef\pgf@temp{\PDFcolor{#1}}% - \edef\pgf@marshal{\noexpand\pgfutil@in@{ g}{\pgf@temp}}% - \pgf@marshal% - \ifpgfutil@in@% - \expandafter\pgfutil@context@parse@gray\pgf@temp\pgf@stop{#1}% - \else% - \edef\pgf@marshal{\noexpand\pgfutil@in@{ rg}{\pgf@temp}}% - \pgf@marshal% - \ifpgfutil@in@% - \expandafter\pgfutil@context@parse@rgb\pgf@temp\pgf@stop{#1}% - \else% - \PackageError{pgf}{Color #1 has an unsupported color model.}{}% - \pgfutil@definecolor{#1}{gray}{0} - \fi% - \fi% + \edef\pgf@marshal{\noexpand\pgfutil@in@{rg}{\pgf@temp}}% + \pgf@marshal + \ifpgfutil@in@ + \expandafter\pgfutil@context@parse@rgb\pgf@temp\pgf@stop{#1}% + \else + \edef\pgf@marshal{\noexpand\pgfutil@in@{g}{\pgf@temp}}% + \pgf@marshal + \ifpgfutil@in@ + \expandafter\pgfutil@context@parse@gray\pgf@temp\pgf@stop{#1}% + \else + \edef\pgf@marshal{\noexpand\pgfutil@in@{k}{\pgf@temp}}% + \pgf@marshal + \ifpgfutil@in@ + \expandafter\pgfutil@context@parse@cmyk\pgf@temp\pgf@stop{#1}% + \else + \pgferror{Color #1 has an unsupported color model.}% + \pgfutil@definecolor{#1}{gray}{0}% + \fi + \fi + \fi } \def\pgfutil@context@parse@gray#1 g#2\pgf@stop#3{% @@ -165,6 +174,15 @@ \pgfutil@definecolor{#5}{rgb}{#1,#2,#3} } +\def\pgfutil@context@parse@cmyk#1 #2 #3 #4k#5\pgf@stop #6{% + \pgfutil@definecolor{#6}{cmyk}{#1,#2,#3,#4}% +} + +\def\pgfutil@emu@cmyk#1#2,#3,#4,#5\@nil{% + \expandafter\def\csname\string\color@#1\endcsname + {\xcolor@{}{}{cmyk}{#2,#3,#4,#5}}% +} + % Make this command available in general: \let\colorlet=\pgfutil@colorlet @@ -253,12 +271,18 @@ \newbox\pgfutil@tempboxa -\newdimen\pgfutil@tempdima -\newdimen\pgfutil@tempdimb - \newbox \pgfutil@voidb@x \newtoks \pgfutil@toks@ +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempcnta\pgfutil@tempcnta +\let\pgfmath@tempcntb\pgfutil@tempcntb + +% From LaTeX +\newskip\pgfutil@flushglue +\pgfutil@flushglue=0pt plus 1fil + % Module stuff \def\pgfutil@usemodule#1{\usemodule[#1]} @@ -332,9 +356,9 @@ % The following is still messy and needs to be cleanup up (everything % prefixed by pgfutil@): -\def\PackageInfo#1#2{} -\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% -\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% +%\def\PackageInfo#1#2{} +%\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% +%\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% \long\def\AtBeginDocument#1{#1}% \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def index f9681aa4a56..c990a3730a4 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def @@ -10,12 +10,21 @@ \catcode`\@=11\relax +\pgfutil@format@is@latextrue + \let\pgfutil@auxout=\@auxout +\def\pgfutil@writetoaux#1{\if@filesw\write\pgfutil@auxout{#1}\fi} + \let\pgfutil@tempcnta=\@tempcnta \let\pgfutil@tempcntb=\@tempcntb \let\pgfutil@voidb@x=\voidb@x \let\pgfutil@toks@=\toks@ +\let\pgfutil@packageerror=\PackageError +\let\pgfutil@packagewarning=\PackageWarning + +\def\pgfutil@protect{\protect} + \def\pgfutil@definecolor{\definecolor} \def\pgfutil@color{\color} @@ -38,6 +47,11 @@ \pgf@next{#2}{#3}% } +\let\pgfutil@raggedleft\raggedleft +\let\pgfutil@raggedright\raggedright + +\let\pgfutil@flushglue=\@flushglue + \def\pgfutil@font@tiny{\tiny} \def\pgfutil@font@scriptsize{\scriptsize} \def\pgfutil@font@footnotesize{\footnotesize} @@ -59,13 +73,30 @@ \let\pgfutil@tempboxa=\@tempboxa -\let\pgfutil@tempdima=\@tempdima -\let\pgfutil@tempdimb=\@tempdimb +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempcnta\pgfutil@tempcnta +\let\pgfmath@tempcntb\pgfutil@tempcntb -\AtEndDocument{\the\pgfutil@everybye} + +\AtBeginDocument{\AtEndDocument{\par\vfil\penalty-10000\relax\the\pgfutil@everybye}} \def\pgfutil@insertatbegincurrentpagefrombox#1{% - \global\setbox\pgfutil@abb\hbox{\unhbox\pgfutil@abb#1}% + \edef\pgf@temp{\the\wd\pgfutil@abb}% + \global\setbox\pgfutil@abb\hbox{% + \unhbox\pgfutil@abb + % + % the order in which \pgfutil@insertatbegincurrentpagefrombox + % matters unless we make the following -shift! + % To see this, consider writing two such statements. The second + % one will (naturally) be placed more to the right, although there + % is no apparent reason why it should. + % + % CF observed problems when placing patterns in XObjects without + % this skip (dvipdfmx driver for pgfplots shader=interp) + \hskip-\pgf@temp\relax + #1% + }% } \newbox\pgfutil@abb% \def\pgfutil@insertatbegincurrentpage#1{% @@ -82,14 +113,14 @@ % Add at begin page stuff \setbox\@cclv=\vbox{% \setbox\z@=\hbox{\pgfutil@abe\unhbox\pgfutil@abb\pgfutil@abc\global\let\pgfutil@abc\pgfutil@empty}% - \wd\z@=\z@ - \ht\z@=\z@ - \dp\z@=\z@ - \box\z@ + \wd\z@=\z@% + \ht\z@=\z@% + \dp\z@=\z@% + \box\z@% % if TeX changes into vertical mode, it inserts \parskip and % \lineskip. Disable it here: - \nointerlineskip - \ifvbox\@cclv \unvbox\@cclv \else\hsize=\wd\@cclv \unhbox\@cclv \fi% + \nointerlineskip% + \ifvbox\@cclv \unvbox\@cclv \else\hsize=\wd\@cclv \noindent\unhbox\@cclv \fi% %\box\@cclv % using \box instead of \unhbox or \unvbox % has the advantage that glue settings won't be @@ -98,4 +129,30 @@ }% } +% Preview hack: preview.sty hacks into \shipout (which is ok), but +% does not honour everyshi.sty (which is not ok). This causes everyshi +% material to get lost. + +\AtBeginDocument{ + \@ifpackageloaded{preview}{% + % Ok, package loaded. Swap definitions of everyshi.sty's shipout + % and preview.sty's shipout: + \let\pgf@temp\pr@shipout% This is the original shipout + \let\pr@shipout\@EveryShipout@Shipout% This is what preview.sty should call + \let\@EveryShipout@Org@Shipout\pgf@temp% Everyshi should now use the original one + }{}% +} + + +% Guess the driver: + +\def\pgfutil@guessdriver{ + \ifx\HCode\@undefined% + \edef\pgfsysdriver{pgfsys-\Gin@driver}% should be right + \else% + \def\pgfsysdriver{pgfsys-tex4ht.def}% should be right + \fi% +} + + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-plain.def b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-plain.def index c09cf21fe0f..31d0d21d10c 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-plain.def +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-plain.def @@ -9,6 +9,7 @@ +\pgfutil@format@is@plaintrue % The aux files, needed for reading back coordinates @@ -17,7 +18,7 @@ \csname newwrite\endcsname\pgfutil@auxout \csname openout\endcsname\pgfutil@auxout\jobname.pgf } - +\def\pgfutil@writetoaux#1{\write\pgfutil@auxout{#1}} % XColor-like support for plain TeX @@ -147,7 +148,7 @@ \def\pgfutil@minipage[#1]#2{% \hbox to#2\bgroup% \hsize=#2\relax% - \vbox\bgroup\leavevmode% + \vbox\bgroup\noindent% } \def\pgfutil@endminipage{\egroup\egroup} @@ -159,14 +160,18 @@ \ifx\pdfoutput\relax\alloc@0\count\countdef\insc@unt\pdfoutput\fi \def\pgfutil@guessdriver{ - \ifcase\pdfoutput% - \ifx\XeTeXversion\@undefined - \def\pgfsysdriver{pgfsys-dvips.def}% hopefully - \else - \def\pgfsysdriver{pgfsys-xetex.def}% should be right - \fi + \ifx\HCode\@undefined% + \ifcase\pdfoutput% + \ifx\XeTeXversion\@undefined + \def\pgfsysdriver{pgfsys-dvips.def}% hopefully + \else + \def\pgfsysdriver{pgfsys-xetex.def}% should be right + \fi + \else% + \def\pgfsysdriver{pgfsys-pdftex.def}% should be right + \fi% \else% - \def\pgfsysdriver{pgfsys-pdftex.def}% should be right + \def\pgfsysdriver{pgfsys-tex4ht.def}% should be right \fi% } @@ -206,9 +211,14 @@ \newbox\pgfutil@tempboxa -\newdimen\pgfutil@tempdima -\newdimen\pgfutil@tempdimb +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempdima\pgfutil@tempdima +\let\pgfmath@tempcnta\pgfutil@tempcnta +\let\pgfmath@tempcntb\pgfutil@tempcntb +% From LaTeX +\newskip\pgfutil@flushglue +\pgfutil@flushglue=0pt plus 1fil % Module stuff @@ -228,8 +238,7 @@ -% Hack shipout. Should perhaps use atbegshi? Not in standard distribution, currently... -% Code inspired (but patched...) from everyshi.sty: +% Hack shipout. Now use atbegshi \def\pgfutil@insertatbegincurrentpagefrombox#1{% \global\setbox\pgfutil@abb\hbox{\unhbox\pgfutil@abb#1}% @@ -244,39 +253,34 @@ } \let\pgfutil@abe\pgfutil@empty% -\def\pgfutil@@EveryShipout@Shipout{% - \afterassignment\pgfutil@@EveryShipout@Test - \setbox255= % -} -\def\pgfutil@@EveryShipout@Test{% - \ifvoid\@cclv\relax - \aftergroup\pgfutil@EveryShipout@Output - \else - \pgfutil@EveryShipout@Output - \fi% -} -\def\pgfutil@EveryShipout@Output{% - \setbox255=\vbox{% - \setbox0=\hbox{\pgfutil@abe\unhbox\pgfutil@abb\pgfutil@abc\global\let\pgfutil@abc\pgfutil@empty}% - \wd0=0pt% - \ht0=0pt% - \dp0=0pt% - \box0% - \unvbox255% - }% - \pgfutil@@EveryShipout@Org@Shipout\box\@cclv% -} -\let\pgfutil@@EveryShipout@Org@Shipout\shipout -\let\shipout\pgfutil@@EveryShipout@Shipout - - +% Code by Heiko Oberdiek on ctt +\input atbegshi.sty\relax +\AtBeginShipout{% + \setbox\AtBeginShipoutBox=\vbox{% + \setbox0=\hbox{% + \begingroup + \pgfutil@abe + \unhbox\pgfutil@abb + \pgfutil@abc + \global\let\pgfutil@abc\pgfutil@empty + \endgroup + }% + \wd0=0pt\relax + \ht0=0pt\relax + \dp0=0pt\relax + \box0 % + \nointerlineskip + \box\AtBeginShipoutBox + }% +}% +% End of HO code % The following is still messy and needs to be cleanup up (everything % prefixed by pgfutil@): -\def\PackageInfo#1#2{} -\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% -\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% +%\def\PackageInfo#1#2{} +%\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% +%\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% \long\def\AtBeginDocument#1{#1}% \endinput |