summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex579
1 files changed, 415 insertions, 164 deletions
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 782d0d44748..b2f55e82923 100644
--- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
+++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
@@ -35,6 +35,16 @@
% Simple stuff
+% \pgfutil@trimspaces{<token list>}
+%
+% Removes spaces on both sides of <token list>. Same as trimspaces.sty
+\catcode`\Q=3
+\def\pgfutil@trimspaces#1{%
+ \romannumeral-`0\pgfutil@trimspaces@\noexpand#1Q Q}
+\def\pgfutil@trimspaces@#1 Q{\pgfutil@trimspaces@@#1Q}
+\def\pgfutil@trimspaces@@#1Q#2{#1}
+\catcode`\Q=11
+
% \pgfutil@ifundefined{<macro name with backslash>}
% {<is undefined code>}{<is defined code>}
%
@@ -99,6 +109,20 @@
\def\:{\pgfutil@xifnch} \expandafter\gdef\: {\futurelet\pgfutil@let@token\pgfutil@ifnch}
}
+% pgfutil@ignorespaces
+
+\def\pgfutil@ignorespaces
+ {\ifx\pgfutil@let@token\pgfutil@sptoken
+ \expandafter\pgfutil@ignorespaces@helper
+ \else
+ \expandafter\pgfutil@next
+ \fi}
+
+{
+ \def\:{\pgfutil@ignorespaces@helper}
+ \expandafter\gdef\: {\futurelet\pgfutil@let@token\pgfutil@ignorespaces}
+}
+
% pgfutil@in@
\newif\ifpgfutil@in@
@@ -106,13 +130,13 @@
% Usage:
% \pgfutil@in@{one}{three two one}
% \ifpgfutil@in@
-% -> will be true!
+% -> will be true!
% \else
% \fi
%
% \pgfutil@in@{,}{1234,456567}
% \ifpgfutil@in@
-% -> will be true!
+% -> will be true!
% \else
% \fi
\def\pgfutil@in@#1#2{%
@@ -145,7 +169,7 @@
% pgfutil@IfFileExists
-%\chardef\pgfutil@inputcheck0
+\chardef\pgfutil@inputcheck0
\def\pgfutil@IfFileExists#1#2#3{%
\openin\pgfutil@inputcheck=#1 %
\ifeof\pgfutil@inputcheck
@@ -308,58 +332,119 @@
%
\begingroup
- \catcode`\"=12
- \edef\pgf@loc@TMPa{"}%
- %
- % prepares file names by checking for double colons.
- %
- % If '#1' is a usual file name without anything fancy, \pgfretval
- % will simply contain it. However, if '#1' contains double colons
- % (introduces, for example, by pdftex because there are white
- % spaces in '#1'), the routine
- % - removes the double colons,
- % - re-inserts them outside of the string.
- %
- % \pgfutilpreparefilename{file.tex} -> file.tex
- % \pgfutilpreparefilename{"A file name".file} -> "A file name.file"
- %
- % The resulting file name is returned in '\pgfretval',
- % furthermore, a *quoted* version of the file name is returned in
- % \pgfretvalquoted. The latter result is to have some sort of
- % output normalisation: if the file name as such contains double
- % quotes, we don't want to insert another set of them.
- %
- % This special handling has the following purposes:
- % 1. Both, treatment of white spaces and double colons is not
- % properly defined in TeX. Thus, we should only work with them if
- % necessary and maintain backwards compatibility as far as
- % possible.
- % 2. It *should* work if there are spaces.
- %
- \gdef\pgfutilpreparefilename#1{%
- \begingroup
- \ifnum\the\catcode`\"=13
- \pgfutilconvertdcolon
- \fi
- \xdef\pgf@temp{#1}%
- \endgroup
- \expandafter\pgfutil@in@\expandafter"\expandafter{\pgf@temp}%
- \ifpgfutil@in@
- \def\pgf@loc@TMPa{\pgfutilstrreplace{"}{}}%
- \expandafter\pgf@loc@TMPa\expandafter{\pgf@temp}%
- \edef\pgfretval{"\pgfretval"}% re-insert quotes! Otherwise, TeX can't use the file name.
- \let\pgfretvalquoted=\pgfretval
- \else
- \let\pgfretval=\pgf@temp
- \edef\pgfretvalquoted{"\pgfretval"}%
- \fi
- }%
- \catcode`\"=13
- \xdef\pgfutilconvertdcolon{%
- \noexpand\def\noexpand"{\pgf@loc@TMPa}%
- }%
+ \catcode`\"=12
+ \edef\pgf@loc@TMPa{"}%
+ %
+ % prepares file names by checking for double colons.
+ %
+ % If '#1' is a usual file name without anything fancy, \pgfretval
+ % will simply contain it. However, if '#1' contains double colons
+ % (introduces, for example, by pdftex because there are white
+ % spaces in '#1'), the routine
+ % - removes the double colons,
+ % - re-inserts them outside of the string.
+ %
+ % \pgfutilpreparefilename{file.tex} -> file.tex
+ % \pgfutilpreparefilename{"A file name".file} -> "A file name.file"
+ %
+ % The resulting file name is returned in '\pgfretval',
+ % furthermore, a *quoted* version of the file name is returned in
+ % \pgfretvalquoted. The latter result is to have some sort of
+ % output normalisation: if the file name as such contains double
+ % quotes, we don't want to insert another set of them.
+ %
+ % This special handling has the following purposes:
+ % 1. Both, treatment of white spaces and double colons is not
+ % properly defined in TeX. Thus, we should only work with them if
+ % necessary and maintain backwards compatibility as far as
+ % possible.
+ % 2. It *should* work if there are spaces.
+ %
+ \gdef\pgfutilpreparefilename#1{%
+ \begingroup
+ \ifnum\the\catcode`\"=13
+ \pgfutilconvertdcolon
+ \fi
+ \xdef\pgf@temp{#1}%
+ \endgroup
+ \expandafter\pgfutil@in@\expandafter"\expandafter{\pgf@temp}%
+ \ifpgfutil@in@
+ \def\pgf@loc@TMPa{\pgfutilstrreplace{"}{}}%
+ \expandafter\pgf@loc@TMPa\expandafter{\pgf@temp}%
+ \edef\pgfretval{"\pgfretval"}% re-insert quotes! Otherwise, TeX can't use the file name.
+ \let\pgfretvalquoted=\pgfretval
+ \else
+ \let\pgfretval=\pgf@temp
+ \edef\pgfretvalquoted{"\pgfretval"}%
+ \fi
+ }%
+ \catcode`\"=13
+ \xdef\pgfutilconvertdcolon{%
+ \noexpand\def\noexpand"{\pgf@loc@TMPa}%
+ }%
\endgroup
+% Converts an arbitrary command (without arguments) to a string in which all characters
+% have category 12.
+%
+% #1: a macro name (which takes no arguments)
+% #2: a macro name which will be assigned to '#1' converted to string.
+%
+% This uses '\meaning#1' hackery.
+\def\pgfutil@command@to@string#1#2{%
+ \expandafter\pgfutil@command@to@string@@\meaning#1\pgfutil@EOI{#2}%
+}%
+\xdef\pgfutil@glob@TMPa{\meaning\pgfutil@empty}%
+\expandafter\def\expandafter\pgfutil@command@to@string@@\pgfutil@glob@TMPa#1\pgfutil@EOI#2{%
+ \def#2{#1}%
+}%
+\begingroup
+\catcode`\|=0
+\catcode`\\=12
+|gdef|pgfutil@backslash@as@other{\}%
+|endgroup
+
+% Checks if the token sequence #1 (unexpanded) contains a macro and
+% invokes #2 if so and #3 if not.
+\def\pgfutilifcontainsmacro#1#2#3{%
+ \def\pgf@marshal{#1}%
+ \pgfutil@command@to@string\pgf@marshal\pgf@marshal
+ \edef\pgf@marshal{\noexpand\pgfutil@in@{\pgfutil@backslash@as@other}{\pgf@marshal}}%
+ \pgf@marshal
+ \ifpgfutil@in@
+ \def\pgf@marshal{#2}%
+ \else
+ \def\pgf@marshal{#3}%
+ \fi
+ \pgf@marshal
+}%
+
+% Tests if string '#2' starts with pattern '#1'.
+%
+% If so, it executes #3 and defines \pgfretval to contain the
+% suffix which is not equal to #1. Otherwise it executes #4.
+\def\pgfutilifstartswith#1#2#3#4{%
+ \def\pgfutilifstartswith@ ##1#1##2\pgf@EOI{%
+ \def\pgfutil@tmp{##1}%
+ \ifx\pgfutil@tmp\pgfutil@empty
+ % Ah - a hit!
+ %
+ % define \pgfretval to be the suffix...
+ \def\pgfutil@tmp#1####1\pgf@EOI{%
+ \def\pgfretval{####1}%
+ }%
+ \pgfutil@tmp#2\pgf@EOI%
+ %
+ % ... and execute the <true> code:
+ #3\relax%
+ \else
+ % hm. No such prefix.
+ #4\relax%
+ \fi
+ }%
+ \pgfutilifstartswith@#2--#1\pgf@EOI%
+}%
+
% Usage:
% \pgfutilstrreplace{<token>}{<replacement>}{<string>}
%
@@ -369,138 +454,286 @@
% #2: zero, one or more tokens which will be inserted instead of '#1'.
% #3: the string to search in
\long\def\pgfutilstrreplace#1#2#3{%
- \def\pgfretval{}%
- \long\def\pgfutil@search@and@replace@@##1#1##2\pgf@EOI{%
- \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval ##1#2}%
- \pgfutil@search@and@replace@loop{#1}{##2}%
- }%
- \pgfutil@search@and@replace@loop{#1}{#3}%
+ \def\pgfretval{}%
+ \long\def\pgfutil@search@and@replace@@##1#1##2\pgf@EOI{%
+ \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval ##1#2}%
+ \pgfutil@search@and@replace@loop{#1}{##2}%
+ }%
+ \pgfutil@search@and@replace@loop{#1}{#3}%
}
\long\def\pgfutil@search@and@replace@loop#1#2{%
- \pgfutil@in@{#1}{#2}%
- \ifpgfutil@in@
- \def\pgf@loc@TMPa{\pgfutil@search@and@replace@@ #2\pgf@EOI}%
- \else
- \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #2}%
- \let\pgf@loc@TMPa=\relax
- \fi
- \pgf@loc@TMPa
+ \pgfutil@in@{#1}{#2}%
+ \ifpgfutil@in@
+ \def\pgf@loc@TMPa{\pgfutil@search@and@replace@@ #2\pgf@EOI}%
+ \else
+ \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #2}%
+ \let\pgf@loc@TMPa=\relax
+ \fi
+ \pgf@loc@TMPa
}%
% Solves a linear equation system of size 2x2 using gauss elimination.
%
% It employs TeX register arithmetics to do so.
% #1: should contain 4 sets of braces with matrix entries,
-% {<a11>}{<a12>}
-% {<a21>}{<a22>}
-% where each entry should be a number without unit.
-% It is acceptable if '#1' is a macro which expands to the expected
-% format.
+% {<a11>}{<a12>}
+% {<a21>}{<a22>}
+% where each entry should be a number without unit.
+% It is acceptable if '#1' is a macro which expands to the expected
+% format.
% #2: should contain 2 sets of braces with the right-hand-side,
-% {<r1>}{<r2>}
-% where each entry should be a number without unit.
-% It is acceptable if '#2' is a macro which expands to the expected
-% format.
+% {<r1>}{<r2>}
+% where each entry should be a number without unit.
+% It is acceptable if '#2' is a macro which expands to the expected
+% format.
%
% It will assign \pgfmathresult to contain two sets of braces with the
% result.
%
% Example:
% \pgfutilsolvetwotwoleq{
-% {0.24}{1}
-% {-0.97}{0}
+% {0.24}{1}
+% {-0.97}{0}
% }{
-% {-7}
-% {18}
+% {-7}
+% {18}
% }
% -> yields \pgfmathresult={−18.55618}{−2.54642}
%
% The algorithm employs column pivotisation.
+%
+% If the matrix is singular, the routine will return {}.
\def\pgfutilsolvetwotwoleq#1#2{%
- \begingroup
- \dimendef\aa=0
- \dimendef\ab=1
- \dimendef\ba=2
- \dimendef\bb=3
- \dimendef\ra=4
- \dimendef\rb=5
- \dimendef\tmpa=6
- \dimendef\tmpb=7
- \edef\pgf@temp{#1}%
- \expandafter\pgfutilsolvetwotwoleq@A\pgf@temp
- \edef\pgf@temp{#2}%
- \expandafter\pgfutilsolvetwotwoleq@r\pgf@temp
- %
- \pgfutilsolvetwotwoleq@ifislarger\aa\ba{%
- % identity "permutation":
- \def\Pa{a}%
- \def\Pb{b}%
- }{%
- % permutation matrix: switch rows!
- \def\Pa{b}%
- \def\Pb{a}%
- }%
- % \pivot := 1/aa
- \pgfmathreciprocal@
- {\csname m\Pa a\endcsname}%
- \let\pivot=\pgfmathresult
- %
- % \factor := 1/aa * ba
- \csname \Pb a\endcsname=\pivot\csname \Pb a\endcsname
- \edef\factor{\expandafter\pgf@sys@tonumber\csname \Pb a\endcsname}%
- %
- % bb -= ba/aa * ab
- \tmpa=-\factor\csname \Pa b\endcsname
- \advance\csname \Pb b\endcsname by\tmpa
- %
- % rb -= ba/aa * ra
- \tmpa=-\factor\csname r\Pa\endcsname
- \advance\csname r\Pb\endcsname by\tmpa
- %
- % xb := rb / bb (the modified rb and modified bb!)
- \pgfmathdivide@
- {\expandafter\pgf@sys@tonumber\csname r\Pb\endcsname}
- {\expandafter\pgf@sys@tonumber\csname \Pb b\endcsname}%
- \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult
- %
- % ra -= xb * ab
- \tmpa=\csname pgfmathresult\Pb\endcsname\csname \Pa b\endcsname
- \advance\csname r\Pa\endcsname by-\tmpa
- %
- % xa := 1/aa * ra (the modified ra!)
- \tmpa=\pivot\csname r\Pa\endcsname
- \expandafter\edef\csname pgfmathresult\Pa\endcsname{\pgf@sys@tonumber\tmpa}%
- %
- \edef\pgfmathresult{%
- {\csname pgfmathresult\Pa\endcsname}%
- {\csname pgfmathresult\Pb\endcsname}%
- }%
- \pgfmath@smuggleone\pgfmathresult
- \endgroup
+ \begingroup
+ \dimendef\aa=0
+ \dimendef\ab=1
+ \dimendef\ba=2
+ \dimendef\bb=3
+ \dimendef\ra=4
+ \dimendef\rb=5
+ \dimendef\tmpa=6
+ \dimendef\tmpb=7
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutilsolvetwotwoleq@A\pgf@temp
+ \edef\pgf@temp{#2}%
+ \expandafter\pgfutilsolvetwotwoleq@r\pgf@temp
+ %
+ \pgfutilsolvetwotwoleq@ifislarger\aa\ba{%
+ % identity "permutation":
+ \def\Pa{a}%
+ \def\Pb{b}%
+ }{%
+ % permutation matrix: switch rows!
+ \def\Pa{b}%
+ \def\Pb{a}%
+ }%
+ % \pivot := 1/aa
+ \tmpa=\csname m\Pa a\endcsname pt %
+ \ifdim\tmpa<0pt \tmpa=-\tmpa\fi
+ \ifdim\tmpa<0.0001pt
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \pgfmathreciprocal@
+ {\csname m\Pa a\endcsname}%
+ \let\pivot=\pgfmathresult
+ %
+ % \factor := 1/aa * ba
+ \csname \Pb a\endcsname=\pivot\csname \Pb a\endcsname
+ \edef\factor{\expandafter\pgf@sys@tonumber\csname \Pb a\endcsname}%
+ %
+ % bb -= ba/aa * ab
+ \tmpa=-\factor\csname \Pa b\endcsname
+ \advance\csname \Pb b\endcsname by\tmpa
+ %
+ % rb -= ba/aa * ra
+ \tmpa=-\factor\csname r\Pa\endcsname
+ \advance\csname r\Pb\endcsname by\tmpa
+ %
+ \tmpa=\csname \Pb b\endcsname%
+ \ifdim\tmpa<0pt \tmpa=-\tmpa\fi
+ \ifdim\tmpa<0.0001pt
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ % xb := rb / bb (the modified rb and modified bb!)
+ \pgfmathdivide@
+ {\expandafter\pgf@sys@tonumber\csname r\Pb\endcsname}
+ {\expandafter\pgf@sys@tonumber\csname \Pb b\endcsname}%
+ \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult
+ %
+ % ra := ra - xb * ab
+ \tmpa=\csname pgfmathresult\Pb\endcsname\csname \Pa b\endcsname
+ \advance\csname r\Pa\endcsname by-\tmpa
+ %
+ % xa := 1/aa * ra (the modified ra!)
+ \tmpa=\pivot\csname r\Pa\endcsname
+ \expandafter\edef\csname pgfmathresult\Pa\endcsname{\pgf@sys@tonumber\tmpa}%
+ %
+ \edef\pgfmathresult{%
+ {\csname pgfmathresult\Pa\endcsname}%
+ {\csname pgfmathresult\Pb\endcsname}%
+ }%
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
}%
+
\def\pgfutilsolvetwotwoleq@ifislarger#1#2#3#4{%
- \tmpa=#1
- \ifdim\tmpa<0pt
- \multiply\tmpa by-1
- \fi
- \tmpb=#2
- \ifdim\tmpb<0pt
- \multiply\tmpb by-1
- \fi
- \ifdim\tmpa>\tmpb
- #3%
- \else
- #4%
- \fi
+ \tmpa=#1
+ \ifdim\tmpa<0pt
+ \multiply\tmpa by-1
+ \fi
+ \tmpb=#2
+ \ifdim\tmpb<0pt
+ \multiply\tmpb by-1
+ \fi
+ \ifdim\tmpa>\tmpb
+ #3%
+ \else
+ #4%
+ \fi
+}%
+
+\def\pgfutilsolvetwotwoleqfloat@ifislarger#1#2#3#4{%
+ \pgfmathfloatabs@{#1}\let\tmpa=\pgfmathresult
+ \pgfmathfloatabs@{#2}\let\tmpb=\pgfmathresult
+ \pgfmathfloatlessthan@{\tmpb}{\tmpa}%
+ \ifpgfmathfloatcomparison
+ #3%
+ \else
+ #4%
+ \fi
}%
\def\pgfutilsolvetwotwoleq@A#1#2#3#4{%
- \def\maa{#1}\def\mab{#2}%
- \def\mba{#3}\def\mbb{#3}%
- \aa=#1pt \ab=#2pt
- \ba=#3pt \bb=#4pt
+ \def\maa{#1}\def\mab{#2}%
+ \def\mba{#3}\def\mbb{#3}%
+ \aa=#1pt \ab=#2pt
+ \ba=#3pt \bb=#4pt
}
\def\pgfutilsolvetwotwoleq@r#1#2{%
- \ra=#1pt \rb=#2pt
+ \ra=#1pt \rb=#2pt
+}%
+\def\pgfutilsolvetwotwoleqfloat@A#1#2#3#4{%
+ \pgfmathfloatparsenumber{#1}\let\maa=\pgfmathresult
+ \pgfmathfloatparsenumber{#2}\let\mab=\pgfmathresult
+ \pgfmathfloatparsenumber{#3}\let\mba=\pgfmathresult
+ \pgfmathfloatparsenumber{#4}\let\mbb=\pgfmathresult
+}
+\def\pgfutilsolvetwotwoleqfloat@r#1#2{%
+ \pgfmathfloatparsenumber{#1}\let\ra=\pgfmathresult
+ \pgfmathfloatparsenumber{#2}\let\rb=\pgfmathresult
+}%
+
+% Same as \pgfutilsolvetwotwoleq, but using floating point
+% arithmetics. The return value is still in fixed point.
+\def\pgfutilsolvetwotwoleqfloat#1#2{%
+ \begingroup
+ \pgfmathfloatcreate{1}{1.0}{-4}% FIXME : use a smaller threshold for FPU?
+ \let\thresh=\pgfmathresult
+ %
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutilsolvetwotwoleqfloat@A\pgf@temp
+ \edef\pgf@temp{#2}%
+ \expandafter\pgfutilsolvetwotwoleqfloat@r\pgf@temp
+ %
+ \pgfutilsolvetwotwoleqfloat@ifislarger\maa\mba{%
+ % identity "permutation":
+ \def\Pa{a}%
+ \def\Pb{b}%
+ }{%
+ % permutation matrix: switch rows!
+ \def\Pa{b}%
+ \def\Pb{a}%
+ }%
+ % \pivot := 1/aa
+ \expandafter\pgfmathfloatabs@\expandafter{\csname m\Pa a\endcsname}%
+ \let\tmpa=\pgfmathresult
+ \pgfmathfloatlessthan@{\tmpa}{\thresh}%
+ \ifpgfmathfloatcomparison
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \expandafter\pgfmathfloatreciprocal@\expandafter{\csname m\Pa a\endcsname}%
+ \let\pivot=\pgfmathresult
+ %
+ % \factor := 1/aa * ba
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pb a\endcsname}{\pivot}%
+ \let\factor=\pgfmathresult
+ \expandafter\let\csname m\Pb a\endcsname=\factor
+ %
+ % bb -= ba/aa * ab
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pa b\endcsname}{\factor}%
+ \let\tmpa=\pgfmathresult
+ \expandafter\pgfmathfloatsubtract@\expandafter{\csname m\Pb b\endcsname}{\tmpa}%
+ \expandafter\let\csname m\Pb b\endcsname=\pgfmathresult
+ %
+ % rb -= ba/aa * ra
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname r\Pa\endcsname}{\factor}%
+ \let\tmpa=\pgfmathresult
+ \expandafter\pgfmathfloatsubtract@\expandafter{\csname r\Pb\endcsname}{\tmpa}%
+ \expandafter\let\csname r\Pb\endcsname=\pgfmathresult
+ %
+ \expandafter\pgfmathfloatabs@\expandafter{\csname m\Pb b\endcsname}%
+ \let\tmpa=\pgfmathresult
+ \pgfmathfloatlessthan@{\tmpa}{\thresh}%
+ \ifpgfmathfloatcomparison
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ % xb := rb / bb (the modified rb and modified bb!)
+ \edef\pgf@marshal{
+ \noexpand\pgfmathfloatdivide@
+ {\csname r\Pb\endcsname}
+ {\csname m\Pb b\endcsname}%
+ }%
+ \pgf@marshal
+ \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult
+ \let\tmpa=\pgfmathresult
+ %
+ % ra := ra - xb * ab
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pa b\endcsname}{\tmpa}%
+ \let\tmpa=\pgfmathresult
+ \expandafter\pgfmathfloatsubtract@\expandafter{\csname r\Pa\endcsname}{\tmpa}%
+ \expandafter\let\csname r\Pa\endcsname=\pgfmathresult
+ %
+ % xa := 1/aa * ra (the modified ra!)
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname r\Pa\endcsname}{\pivot}%
+ \expandafter\let\csname pgfmathresult\Pa\endcsname=\pgfmathresult
+ %
+ \edef\pgfmathresult{%
+ {\csname pgfmathresult\Pa\endcsname}%
+ {\csname pgfmathresult\Pb\endcsname}%
+ }%
+ \expandafter\pgfutilsolvetwotwoleqfloat@to@pgf@range\pgfmathresult
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+
+\def\pgfutilsolvetwotwoleqfloat@to@pgf@range#1#2{%
+ \pgfmathfloatcreate{1}{1.6}{4}\let\pgfutilsolvetwotwoleqfloat@to@pgf@range@max=\pgfmathresult
+ \pgfmathfloatabs@{#1}%
+ \expandafter\pgfmathfloatlessthan@\expandafter{\pgfmathresult}{\pgfutilsolvetwotwoleqfloat@to@pgf@range@max}%
+ \ifpgfmathfloatcomparison
+ \pgfmathfloatabs@{#2}%
+ \expandafter\pgfmathfloatlessthan@\expandafter{\pgfmathresult}{\pgfutilsolvetwotwoleqfloat@to@pgf@range@max}%
+ \ifpgfmathfloatcomparison
+ % ok.
+ \pgfmathfloattofixed{#1}\let\tmpa=\pgfmathresult
+ \pgfmathfloattofixed{#2}%
+ \edef\pgfmathresult{{\tmpa}{\pgfmathresult}}%
+ \else
+ % singular (because PGF cannot represent its result
+ \let\pgfmathresult=\pgfutil@empty
+ \fi
+ \else
+ % singular (because PGF cannot represent its result
+ \let\pgfmathresult=\pgfutil@empty
+ \fi
}%
% there are funny programs which overwrite \read and \write (like
@@ -544,18 +777,36 @@
\def\pgfutil@directlua#1{}
\def\pgfutil@luaescapestring#1{}
\fi
+
+
+\def\pgfutil@shellescape@lua@eightseven#1{%
+ \pgfutil@directlua{os.execute("\pgfutil@luaescapestring{#1}")}%
+}%
+\def\pgfutil@shellescape#1{%
+ \immediate\write18{#1}%
+}%
+\pgfutil@IfUndefined{directlua}{%
+}{%
+ \pgfutil@IfUndefined{lastsavedimageresourcepages}{%
+ % Ah - an old version of luatex. It still supports \write18
+ }{%
+ % take the new variant...
+ \let\pgfutil@shellescape=\pgfutil@shellescape@lua@eightseven
+ }%
+}%
+
% 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
+ \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