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.tex53
1 files changed, 44 insertions, 9 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 6fbaf2687ba..b1c0546c17e 100644
--- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
+++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
@@ -59,20 +59,16 @@
\fi}
% A variant of \pgfutil@ifundefined which will NOT let #1 to \relax it
-% is undefined. However, this macro is not expandable.
+% is undefined.
\def\pgfutil@IfUndefined#1{%
- \begingroup\expandafter\expandafter\expandafter\endgroup
- \expandafter\ifx\csname#1\endcsname\relax
- \expandafter\pgfutil@firstoftwo
- \else
+ \ifcsname#1\endcsname
\expandafter\pgfutil@secondoftwo
+ \else
+ \expandafter\pgfutil@firstoftwo
\fi
}
\long\def\pgfutil@firstofone#1{#1}
\long\def\pgfutil@firstoftwo#1#2{#1}
-\long\def\pgfutil@letfirst#1#2{\pgfutil@letfirst@#1#2\pgfutil@letfirst@end}
-\long\def\pgfutil@letfirst@#1#2#3\pgfutil@letfirst@end{\let#1=#2}
-\def\pgfutil@letfirst@end{}
\long\def\pgfutil@secondoftwo#1#2{#2}
\def\pgfutil@empty{}
\long\def\pgfutil@gobble@until@relax#1\relax{}
@@ -215,6 +211,45 @@
\let\pgfutil@repeat=\fi % this makes \loop...\if...\repeat skippable
+% \pgfutil@switch
+%
+% #1: string to switch on
+% #2: sequence of label-value pairs
+%
+% Example:
+%
+% \pgfutil@switch{foo}{%
+% {foo}{1}%
+% {bar}{2}%
+% {default}{X}%
+% }
+%
+% If a statement with the label `default' exists it will be executed
+% if no other label matches.
+
+\long\def\pgfutil@switch#1#2{%
+ \begingroup
+ \def\pgfutil@switch@selected{}%
+ \pgfutil@switch@collect@statements#2{}{}%
+ \ifcsname pgfutil@switch@choice@\detokenize{#1}\endcsname
+ \expandafter\let\expandafter\pgfutil@switch@selected\csname pgfutil@switch@choice@\detokenize{#1}\endcsname
+ \else
+ \ifdefined\pgfutil@switch@choice@default
+ \let\pgfutil@switch@selected\pgfutil@switch@choice@default
+ \fi
+ \fi
+ \expandafter\endgroup\pgfutil@switch@selected
+}
+
+\long\def\pgfutil@switch@collect@statements#1{%
+ \if\relax\detokenize{#1}\relax
+ \else
+ \afterassignment\pgfutil@switch@collect@statements
+ \expandafter\def\csname pgfutil@switch@choice@\detokenize{#1}\expandafter\endcsname
+ \fi
+}
+
+
% aux-read-hook
\let\pgfutil@aux@read@hook=\relax
@@ -709,7 +744,7 @@
\let\pgfmathresult=\pgfutil@empty
\else
% xb := rb / bb (the modified rb and modified bb!)
- \edef\pgf@marshal{
+ \edef\pgf@marshal{%
\noexpand\pgfmathfloatdivide@
{\csname r\Pb\endcsname}
{\csname m\Pb b\endcsname}%