summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/etoolbox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-04-10 21:54:22 +0000
committerKarl Berry <karl@freefriends.org>2010-04-10 21:54:22 +0000
commitf5059243c2428b73d75e86f6917ce21b28f153df (patch)
treee35165ec392be3e1abe0e5d4b8e53201ce67360c /Master/texmf-dist/tex/latex/etoolbox
parentbc334ef804891be0815c78c3701442ec292d4493 (diff)
etoolbox 1.9 (10apr10)
git-svn-id: svn://tug.org/texlive/trunk@17791 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoolbox')
-rw-r--r--Master/texmf-dist/tex/latex/etoolbox/etoolbox.def6
-rw-r--r--Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty437
2 files changed, 368 insertions, 75 deletions
diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def
index c9f791e4442..b898e8834d0 100644
--- a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def
+++ b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def
@@ -1,6 +1,8 @@
-% $Id: etoolbox.def,v 1.8 2009/08/06 16:50:04 lehman stable $
+% $Id: etoolbox.def,v 1.9 2010/04/10 19:11:49 lehman stable $
-\ProvidesFile{etoolbox.def}[2009/08/06 v1.8 etoolbox debug messages]
+\ProvidesFile{etoolbox.def}
+[\etb@rcsid $Id: etoolbox.def,v 1.9 2010/04/10 19:11:49 lehman stable $
+ etoolbox debug messages]
\begingroup
\makeatletter
diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty
index d1292913092..8c27ea8c3a2 100644
--- a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty
+++ b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty
@@ -1,6 +1,6 @@
-% $Id: etoolbox.sty,v 1.8 2009/08/06 16:50:04 lehman stable $
+% $Id: etoolbox.sty,v 1.9 2010/04/10 19:11:49 lehman stable $
-% Copyright (c) 2007-2009 Philipp Lehman.
+% Copyright (c) 2007-2010 Philipp Lehman.
%
% Permission is granted to copy, distribute and/or modify this
% software under the terms of the LaTeX Project Public License
@@ -14,8 +14,12 @@
% implied warranties of merchantability and fitness for a
% particular purpose.
+\def\etb@rcsid$#1: #2 #3 #4 #5${#4 v#3}
+
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{etoolbox}[2009/08/06 v1.8 e-TeX tools for LaTeX]
+\ProvidesPackage{etoolbox}
+[\etb@rcsid $Id: etoolbox.sty,v 1.9 2010/04/10 19:11:49 lehman stable $
+ e-TeX tools for LaTeX]
\begingroup
\@ifundefined{eTeXversion}
@@ -54,6 +58,7 @@
\protected\def\etb@error{\PackageError{etoolbox}}
\protected\def\etb@info{\PackageInfo{etoolbox}}
+\newcount\etb@tempcnta
% {<cstoken>}[<arguments>][<optarg default>]{<definition>}
@@ -174,7 +179,7 @@
\noexpand\meaning#1\detokenize{macro}:&}
\edef\etb@ifdefmacro{%
\def\noexpand\etb@ifdefmacro##1\detokenize{macro}:##2&}
-\etb@ifdefmacro{\ifblank{#2}\@secondoftwo\@firstoftwo}
+\etb@ifdefmacro{\notblank{#2}}
% {<csname>}{<true>}{<false>}
@@ -194,7 +199,7 @@
\noexpand\meaning#1\detokenize{macro}:&}
\edef\etb@ifdefprefix@i{%
\def\noexpand\etb@ifdefprefix@i##1\detokenize{macro}:##2&}
-\etb@ifdefprefix@i{\ifblank{#1}\@secondoftwo\@firstoftwo}
+\etb@ifdefprefix@i{\notblank{#1}}
% {<csname>}{<true>}{<false>}
@@ -211,7 +216,7 @@
\noexpand\meaning#1\detokenize{macro}:->&}
\edef\etb@ifdefparam{%
\def\noexpand\etb@ifdefparam##1\detokenize{macro}:##2->##3&}
-\etb@ifdefparam{\ifblank{#2}\@secondoftwo\@firstoftwo}
+\etb@ifdefparam{\notblank{#2}}
% {<csname>}{<true>}{<false>}
@@ -228,7 +233,7 @@
\noexpand\meaning#1\string\protected&}
\edef\etb@ifdefprotected{%
\def\noexpand\etb@ifdefprotected##1\string\protected##2&}
-\etb@ifdefprotected{\ifblank{#2}\@secondoftwo\@firstoftwo}
+\etb@ifdefprotected{\notblank{#2}}
% {<csname>}{<true>}{<false>}
@@ -378,11 +383,13 @@
\etb@ifblank@i#1&&\@secondoftwo\@firstoftwo:}
\long\def\etb@ifblank@i#1#2&#3#4#5:{#4}
+\newcommand{\notblank}[1]{%
+ \etb@ifblank@i#1&&\@firstoftwo\@secondoftwo:}
+
% {<numexpr>}{<comp>}{<numexpr>}{<true>}{<false>}
\newcommand*{\ifnumcomp}[3]{%
- \ifnum\numexpr#1\relax
- #2\numexpr#3\relax
+ \ifnum\numexpr#1\relax#2\numexpr#3\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
@@ -399,11 +406,19 @@
\newcommand*{\ifnumless}[1]{%
\ifnumcomp{#1}<}
+% {<numexpr>}{<true>}{<false>}
+
+\newcommand*{\ifnumodd}[1]{%
+ \ifodd\numexpr#1\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+
% {<dimexpr>}{<comp>}{<dimexpr>}{<true>}{<false>}
\newcommand*{\ifdimcomp}[3]{%
- \ifdim\dimexpr#1\relax
- #2\dimexpr#3\relax
+ \ifdim\dimexpr#1\relax#2\dimexpr#3\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
@@ -420,7 +435,273 @@
\newcommand*{\ifdimless}[1]{%
\ifdimcomp{#1}<}
-% {<string>}{<true>}{<false>}
+% {<expr>}{<true>}{<false>}
+
+\newcommand*{\ifboolexpe}[1]{%
+ \etb@be@beg\etb@be@bgroup#1(&\etb@be@end}
+
+\let\etb@be@true\@empty
+\def\etb@be@false{-\@ne}
+
+\def\etb@be@beg{%
+ \ifnum\numexpr\z@\ifnum\numexpr\z@}
+
+\def\etb@be@end{%
+ <\z@
+ \expandafter\etb@be@false
+ \fi
+ <\z@
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi}
+
+\def\etb@be@bgroup#1(#2&{%
+ \etb@be@egroup#1)&%
+ \ifblank{#2}
+ {}
+ {\etb@be@beg
+ \etb@be@bgroup#2&}}
+
+\def\etb@be@egroup#1)#2&{%
+ \etb@be@and#1and&%
+ \ifblank{#2}
+ {}
+ {\etb@be@end\etb@be@true\etb@be@false
+ \etb@be@egroup#2&}}
+
+\def\etb@be@and#1and#2&{%
+ \etb@be@or#1or&%
+ \ifblank{#2}
+ {}
+ {<\z@
+ \expandafter\@firstofone
+ \else
+ \expandafter\@gobble
+ \fi
+ {=\z@\fi\ifnum\numexpr\m@ne}%
+ \ifnum\numexpr\z@
+ \etb@be@and#2&}}
+
+\def\etb@be@or#1or#2&{%
+ \etb@be@not#1not&%
+ \ifblank{#2}
+ {}
+ {<\z@
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi
+ {=\z@\fi\ifnum\numexpr\z@
+ \ifnum\numexpr\@ne}
+ {=\z@\fi\ifnum\numexpr\z@
+ \ifnum\numexpr\z@}%
+ \etb@be@or#2&}}
+
+\def\etb@be@not#1not#2&{%
+ \etb@be@togl#1togl&%
+ \ifblank{#2}
+ {}
+ {>\z@
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+ {\unless\ifnum\numexpr\m@ne}
+ {\unless\ifnum\numexpr\z@}%
+ \etb@be@not#2&}}
+
+\def\etb@be@togl#1togl#2&{%
+ \etb@be@bool#1bool&%
+ \ifblank{#2}
+ {}
+ {\etb@be@togl@i#2&}}
+
+\def\etb@be@togl@i#1#2&{%
+ \ifcsdef{etb@tgl@#1}
+ {\csname etb@tgl@#1\endcsname\etb@be@true\etb@be@false}
+ {\etb@be@err{Toggle '#1' undefined}{}}%
+ \etb@be@togl#2&}
+
+\def\etb@be@bool#1bool#2&{%
+ \etb@be@test#1test&%
+ \ifblank{#2}
+ {}
+ {\etb@be@bool@i#2&}}
+
+\def\etb@be@bool@i#1#2&{%
+ \ifcsundef{if#1}
+ {\etb@be@err{Boolean '#1' undefined}{}}
+ {\csname if#1\endcsname
+ \else
+ \etb@be@false
+ \fi}%
+ \etb@be@bool#2&}
+
+\def\etb@be@test#1test#2&{%
+ \ifblank{#1}
+ {}
+ {\etb@be@err{The invalid part is: '\detokenize{#1}'}{}}%
+ \ifblank{#2}
+ {}
+ {\etb@be@test@i#2&}}
+
+\def\etb@be@test@i#1#2&{%
+ #1\etb@be@true\etb@be@false
+ \etb@be@test#2&}
+
+\def\etb@be@err#1#2{%
+ \expandafter\ifnum\the\numexpr
+ \expandafter\ifnum\the\currentiftype=-3
+ \expandafter\thr@@
+ \else
+ \expandafter\currentiftype
+ \fi
+ =\thr@@
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+ {=\z@\fi
+ \etb@be@err{#1}{#2\ifnum\numexpr\m@ne}}
+ {\etb@err@expr{#1}#2}}
+
+% {<expr>}{<true>}{<false>}
+
+\newrobustcmd*{\ifboolexpr}[1]{\etb@boolexpr{#1}}
+
+\def\etb@boolexpr#1{%
+ \begingroup
+ \let\etb@br@neg\@firstoftwo
+ \etb@tempcnta\z@
+ \etb@br@beg
+ \etb@br@bgroup#1(&%
+ \etb@br@end
+ \etb@br@eval}
+
+\def\etb@br@beg{%
+ \begingroup
+ \let\etb@br@neg\@firstoftwo
+ \etb@tempcnta\z@}
+
+\def\etb@br@end{%
+ \etb@br@eval\etb@br@true\etb@br@false}
+
+\def\etb@br@eval{%
+ \ifnum\etb@tempcnta<\z@
+ \aftergroup\@secondoftwo
+ \else
+ \aftergroup\@firstoftwo
+ \fi
+ \endgroup}
+
+\def\etb@br@true{%
+ \advance\etb@tempcnta\etb@br@neg\z@\m@ne
+ \let\etb@br@neg\@firstoftwo}%
+
+\def\etb@br@false{%
+ \advance\etb@tempcnta\etb@br@neg\m@ne\z@
+ \let\etb@br@neg\@firstoftwo}%
+
+\def\etb@br@bgroup#1(#2&{%
+ \etb@br@egroup#1)&%
+ \ifblank{#2}
+ {}
+ {\etb@br@beg
+ \etb@br@bgroup#2&}}
+
+\def\etb@br@egroup#1)#2&{%
+ \etb@br@and#1and&%
+ \ifblank{#2}
+ {}
+ {\etb@br@end
+ \etb@br@egroup#2&}}
+
+\def\etb@br@and#1and#2&{%
+ \etb@br@or#1or&%
+ \ifblank{#2}
+ {}
+ {\ifnum\etb@tempcnta<\z@
+ \etb@tempcnta\m@ne
+ \else
+ \etb@tempcnta\z@
+ \fi
+ \etb@br@and#2&}}
+
+\def\etb@br@or#1or#2&{%
+ \etb@br@not#1not&%
+ \ifblank{#2}
+ {}
+ {\ifnum\etb@tempcnta<\z@
+ \etb@tempcnta\z@
+ \else
+ \etb@tempcnta\@ne
+ \fi
+ \etb@br@or#2&}}
+
+\def\etb@br@not#1not#2&{%
+ \etb@br@togl#1togl&%
+ \ifblank{#2}
+ {}
+ {\let\etb@br@neg\@secondoftwo
+ \etb@br@not#2&}}
+
+\def\etb@br@togl#1togl#2&{%
+ \etb@br@bool#1bool&%
+ \ifblank{#2}
+ {}
+ {\etb@br@togl@i#2&}}
+
+\def\etb@br@togl@i#1#2&{%
+ \ifcsdef{etb@tgl@#1}
+ {\csname etb@tgl@#1\endcsname\etb@br@true\etb@br@false}
+ {\etb@err@expr{Toggle '#1' undefined}%
+ \etb@br@false}%
+ \etb@br@togl#2&}
+
+\def\etb@br@bool#1bool#2&{%
+ \etb@br@test#1test&%
+ \ifblank{#2}
+ {}
+ {\etb@br@bool@i#2&}}
+
+\def\etb@br@bool@i#1#2&{%
+ \ifcsundef{if#1}
+ {\etb@err@expr{Boolean '#1' undefined}%
+ \etb@br@false}
+ {\csname if#1\endcsname
+ \etb@br@true
+ \else
+ \etb@br@false
+ \fi}%
+ \etb@br@bool#2&}
+
+\def\etb@br@test#1test#2&{%
+ \ifblank{#1}
+ {}
+ {\etb@err@expr{The invalid part is: '\detokenize{#1}'}}%
+ \ifblank{#2}
+ {}
+ {\etb@br@test@i#2&}}
+
+\def\etb@br@test@i#1#2&{%
+ \ignorespaces#1\etb@br@true\etb@br@false
+ \etb@br@test#2&}
+
+\long\def\etb@err@expr#1{%
+ \etb@error
+ {Invalid boolean expression}
+ {#1.}}
+
+% {<expr>}{<code>}
+
+\newrobustcmd*{\whileboolexpr}[2]{%
+ \etb@boolexpr{#1}{#2\whileboolexpr{#1}{#2}}{}}
+
+% {<expr>}{<code>}
+
+\newrobustcmd*{\unlessboolexpr}[2]{%
+ \etb@boolexpr{#1}{}{#2\unlessboolexpr{#1}{#2}}}
% {<cstoken>}
@@ -475,12 +756,18 @@
% {<cstoken>}{<csname>}
\newrobustcmd*{\letcs}[2]{%
- \expandafter\let\expandafter#1\csname#2\endcsname}
+ \ifcsdef{#2}
+ {\expandafter\let\expandafter#1\csname#2\endcsname}
+ {\undef#1}}
% {<csname>}{<csname>}
\newrobustcmd*{\csletcs}[2]{%
- \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
+ \ifcsdef{#2}
+ {\expandafter\let
+ \csname#1\expandafter\endcsname
+ \csname#2\endcsname}
+ {\csundef{#1}}}
% {<csname>}
@@ -638,7 +925,7 @@
{#1\glueexpr#2\relax}}
\protected\def\etb@err@nolen#1{%
- \etb@error{Length \string#1 undefined}\@eha}
+ \etb@error{Length '\string#1' undefined}\@eha}
% {<name>}
@@ -712,7 +999,7 @@
\fi}}
\protected\def\etb@err@nobool#1{%
- \etb@error{\@backslashchar if#1 undefined}\@eha}
+ \etb@error{Boolean '\@backslashchar if#1' undefined}\@eha}
\def\etb@err@boolval#1{%
\etb@error
@@ -829,25 +1116,25 @@
{\etb@error{\string#1 undefined}\@eha}
{\ifdefmacro{#1}
{\ifdefltxprotect{#1}
- {\letcs\etb@tempa{\expandafter\@gobble\string#1 }%
+ {\letcs\etb@tempa{\expandafter\@gobble\string#1 }%
\@tempswatrue}
- {\let\etb@tempa#1%
+ {\let\etb@tempa#1%
\@tempswafalse}%
- \ifdefparam\etb@tempa
- {\etb@ifscanable\etb@tempa
- {\etb@robustify\etb@tempa
- \let#1\etb@tempa}
- {\etb@error{Failed to robustify \string#1}
- {The command is special and cannot be
- handled by \string\robustify.}%
- \@tempswafalse}}
- {\protected\edef#1{\expandonce\etb@tempa}}
- \if@tempswa
- \ifcsdef{\string#1 }
- {}
- {\csundef{\expandafter\@gobble\string#1 }}%
- \fi
- \undef\etb@tempa}
+ \ifdefparam\etb@tempa
+ {\etb@ifscanable\etb@tempa
+ {\etb@robustify\etb@tempa
+ \let#1\etb@tempa}
+ {\etb@error{Failed to robustify \string#1}
+ {The command is special and cannot be
+ handled by \string\robustify.}%
+ \@tempswafalse}}
+ {\protected\edef#1{\expandonce\etb@tempa}}
+ \if@tempswa
+ \ifcsdef{\string#1 }
+ {}
+ {\csundef{\expandafter\@gobble\string#1 }}%
+ \fi
+ \undef\etb@tempa}
{\etb@error{\string#1 not a macro}\@eha}}}
\def\etb@robustify#1{%
@@ -879,13 +1166,13 @@
{\etb@dbg@info{mac}%
\etb@ifscanable{#1}
{\etb@ifhashcheck{#2}
- {\etb@dbg@info{tok}%
- \etb@ifpattern{#1}{#2}
- {\etb@dbg@info{pat}%
- \etb@dbg@info{pos}\@firstoftwo}
- {\etb@dbg@fail{pat}\@secondoftwo}}
- {\etb@dbg@fail{hsh}\@secondoftwo}}
- {\etb@dbg@fail{tok}\@secondoftwo}}
+ {\etb@dbg@info{tok}%
+ \etb@ifpattern{#1}{#2}
+ {\etb@dbg@info{pat}%
+ \etb@dbg@info{pos}\@firstoftwo}
+ {\etb@dbg@fail{pat}\@secondoftwo}}
+ {\etb@dbg@fail{hsh}\@secondoftwo}}
+ {\etb@dbg@fail{tok}\@secondoftwo}}
{\etb@dbg@fail{mac}\@secondoftwo}}}
\def\etb@ifpatchable@i#1{%
@@ -897,16 +1184,16 @@
\ifdefmacro{#1}
{\etb@dbg@info{mac}%
\ifdefparam{#1}
- {\etb@dbg@info{prm}%
- \etb@ifscanable{#1}
- {\etb@dbg@info{tok}%
- \etb@dbg@info{pos}\@firstoftwo}
- {\etb@dbg@fail{tok}\@secondoftwo}}
- {\etb@dbg@info{prl}%
- \ifdefprotected{#1}
- {\etb@dbg@info{pro}}
- {}%
- \etb@dbg@info{pos}\@firstoftwo}}
+ {\etb@dbg@info{prm}%
+ \etb@ifscanable{#1}
+ {\etb@dbg@info{tok}%
+ \etb@dbg@info{pos}\@firstoftwo}
+ {\etb@dbg@fail{tok}\@secondoftwo}}
+ {\etb@dbg@info{prl}%
+ \ifdefprotected{#1}
+ {\etb@dbg@info{pro}}
+ {}%
+ \etb@dbg@info{pos}\@firstoftwo}}
{\etb@dbg@fail{mac}\@secondoftwo}}}
% [<prefix>]{<cstoken>}{<search>}{<replace>}{<success>}{<failure>}
@@ -964,22 +1251,22 @@
{\etb@dbg@info{mac}%
\ifdefparam{#2}
{\etb@dbg@info{prm}%
- \etb@ifscanable{#2}
- {\etb@ifhashcheck{#3}
- {\etb@dbg@info{tok}%
- \etb@dbg@succ{ret}%
- \etb@hooktocmd@i{#1}{#2}{#3}%
- \@firstoftwo}
- {\etb@dbg@fail{hsh}\@secondoftwo}}
- {\etb@dbg@fail{tok}\@secondoftwo}}
- {\etb@dbg@info{prl}%
- \ifdefprotected{#2}
- {\etb@dbg@info{pro}%
- \etb@dbg@succ{red}%
- \protected}
- {\etb@dbg@succ{red}}%
- \edef#2{#1{\expandonce#2}{\unexpanded{#3}}}%
- \@firstoftwo}}
+ \etb@ifscanable{#2}
+ {\etb@ifhashcheck{#3}
+ {\etb@dbg@info{tok}%
+ \etb@dbg@succ{ret}%
+ \etb@hooktocmd@i{#1}{#2}{#3}%
+ \@firstoftwo}
+ {\etb@dbg@fail{hsh}\@secondoftwo}}
+ {\etb@dbg@fail{tok}\@secondoftwo}}
+ {\etb@dbg@info{prl}%
+ \ifdefprotected{#2}
+ {\etb@dbg@info{pro}%
+ \etb@dbg@succ{red}%
+ \protected}
+ {\etb@dbg@succ{red}}%
+ \edef#2{#1{\expandonce#2}{\unexpanded{#3}}}%
+ \@firstoftwo}}
{\etb@dbg@fail{mac}\@secondoftwo}}}
\long\def\etb@hooktocmd@i#1#2#3{%
@@ -1099,12 +1386,12 @@
\csname etb@lst@#1\endcsname####1\noexpand#2&}%
\long\csdef{etb@lst@#1}####1\noexpand#2####2&{%
\noexpand\ifblank{####1}
- {}
- {\noexpand\etb@doitem####1&}%
+ {}
+ {\noexpand\etb@doitem####1&}%
\noexpand\ifblank{####2}
- {\noexpand\listbreak}
- {\expandafter\noexpand
- \csname etb@lst@#1\endcsname####2}&}}%
+ {\noexpand\listbreak}
+ {\expandafter\noexpand
+ \csname etb@lst@#1\endcsname####2}&}}%
\@tempa}
\long\def\etb@doitem#1#2&{\do{#1#2}}
@@ -1120,11 +1407,15 @@
\newrobustcmd{\listadd}[2]{%
\ifblank{#2}{}{\appto#1{#2|}}}
\newrobustcmd{\listeadd}[2]{%
- \ifblank{#2}{}{\eappto#1{#2|}}}
+ \begingroup
+ \edef\etb@tempa{\endgroup\noexpand\ifblank{#2}}%
+ \etb@tempa{}{\eappto#1{#2|}}}
\newrobustcmd{\listgadd}[2]{%
\ifblank{#2}{}{\gappto#1{#2|}}}
\newrobustcmd{\listxadd}[2]{%
- \ifblank{#2}{}{\xappto#1{#2|}}}
+ \begingroup
+ \edef\etb@tempa{\endgroup\noexpand\ifblank{#2}}%
+ \etb@tempa{}{\xappto#1{#2|}}}
% {<listcsname>}{<string>}