diff options
author | Karl Berry <karl@freefriends.org> | 2011-01-03 23:49:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-01-03 23:49:15 +0000 |
commit | a77deb8a1058df87320fadced52041b60ec60496 (patch) | |
tree | 151fd07d407dd7672fe550a192b7a84369edfe7b /Master/texmf-dist/tex/latex/etoolbox | |
parent | a67046eaf88b2950920809d3a0bcd538ecf911bd (diff) |
etoolbox 2.1 (3jan11)
git-svn-id: svn://tug.org/texlive/trunk@20922 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoolbox')
-rw-r--r-- | Master/texmf-dist/tex/latex/etoolbox/etoolbox.def | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty | 236 |
2 files changed, 197 insertions, 43 deletions
diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def index a14b8fd00c6..0102a515afb 100644 --- a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def +++ b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def @@ -1,7 +1,7 @@ -% $Id: etoolbox.def,v 2.0a 2010/09/12 11:42:38 lehman stable $ +% $Id: etoolbox.def,v 2.1 2011/01/03 19:14:10 lehman stable $ \ProvidesFile{etoolbox.def} -[\csname etb@rcsid\endcsname $Id: etoolbox.def,v 2.0a 2010/09/12 11:42:38 lehman stable $ +[\csname etb@rcsid\endcsname $Id: etoolbox.def,v 2.1 2011/01/03 19:14:10 lehman stable $ etoolbox debug messages] \begingroup diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty index 6556156fe50..ae37d94c400 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 2.0a 2010/09/12 11:42:38 lehman stable $ +% $Id: etoolbox.sty,v 2.1 2011/01/03 19:14:10 lehman stable $ -% Copyright (c) 2007-2010 Philipp Lehman. +% Copyright (c) 2007-2011 Philipp Lehman. % % Permission is granted to copy, distribute and/or modify this % software under the terms of the LaTeX Project Public License @@ -18,7 +18,7 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{etoolbox} -[\etb@rcsid $Id: etoolbox.sty,v 2.0a 2010/09/12 11:42:38 lehman stable $ +[\etb@rcsid $Id: etoolbox.sty,v 2.1 2011/01/03 19:14:10 lehman stable $ e-TeX tools for LaTeX] \begingroup @@ -50,6 +50,7 @@ \@makeother\> \protected\def\etb@error{\PackageError{etoolbox}} +\protected\def\etb@warning{\PackageWarning{etoolbox}} \protected\def\etb@info{\PackageInfo{etoolbox}} \newcount\etb@tempcnta @@ -85,7 +86,7 @@ \newrobustcmd*{\renewrobustcmd}{\@star@or@long\etb@renew@command} \def\etb@renew@command#1{% - \ifundef#1 + \ifundef{#1} {\etb@error{\string#1 undefined}\@ehc} {}% \let\@ifdefinable\@rc@ifdefinable @@ -96,7 +97,7 @@ \newrobustcmd*{\providerobustcmd}{\@star@or@long\etb@provide@command} \def\etb@provide@command#1{% - \ifundef#1 + \ifundef{#1} {\def\reserved@a{\etb@new@command#1}} {\def\reserved@a{\etb@renew@command\reserved@a}}% \reserved@a} @@ -175,8 +176,8 @@ % {<cstoken>}{<true}{<false>} \newcommand{\ifdefprefix}[1]{% - \ifdefmacro#1 - {\etb@ifdefprefix#1} + \ifdefmacro{#1} + {\etb@ifdefprefix{#1}} {\@secondoftwo}} \long\edef\etb@ifdefprefix#1{% \noexpand\expandafter\noexpand\etb@ifdefprefix@i @@ -249,12 +250,12 @@ % {<cstoken>}{<true>}{<false>} \newcommand{\ifdefempty}[1]{% - \ifundef#1 + \ifundef{#1} {\@secondoftwo} - {\ifdefmacro#1 - {\ifdefparam#1 + {\ifdefmacro{#1} + {\ifdefparam{#1} {\@secondoftwo} - {\etb@ifdefempty#1}} + {\etb@ifdefempty{#1}}} {\@secondoftwo}}} \def\etb@ifdefempty#1{% @@ -276,12 +277,12 @@ % {<cstoken>}{<true>}{<false>} \newcommand{\ifdefvoid}[1]{% - \ifundef#1 + \ifundef{#1} {\@firstoftwo} - {\ifdefmacro#1 - {\ifdefparam#1 + {\ifdefmacro{#1} + {\ifdefparam{#1} {\@secondoftwo} - {\etb@ifdefempty#1}} + {\etb@ifdefempty{#1}}} {\@secondoftwo}}} % {<csname>}{<true>}{<false>} @@ -296,11 +297,11 @@ % {<cstoken1>}{<cstoken2>}{<true>}{<false>} \newcommand{\ifdefequal}[2]{% - \ifundef#1 + \ifundef{#1} {\@secondoftwo} - {\ifundef#2 + {\ifundef{#2} {\@secondoftwo} - {\ifx#1#2 + {\ifx#1#2% \expandafter\@firstoftwo \else \expandafter\@secondoftwo @@ -321,22 +322,48 @@ \expandafter\@secondoftwo \fi}}} -% {<cstoken>}{<string>}{<true>}{<false>} +% {<cstoken1>}{<cstoken2>}{<true>}{<false>} -\newrobustcmd{\ifdefstring}[2]{% - \ifundef#1 - {\@secondoftwo} - {\ifdefmacro#1 +\newrobustcmd{\ifdefstrequal}[2]{% + \ifdefmacro{#1} + {\ifdefmacro{#2} {\begingroup \edef\etb@tempa{\expandafter\strip@prefix\meaning#1}% - \edef\etb@tempb{\detokenize{#2}}% + \edef\etb@tempb{\expandafter\strip@prefix\meaning#2}% \ifx\etb@tempa\etb@tempb \aftergroup\@firstoftwo \else \aftergroup\@secondoftwo \fi \endgroup} - {\@secondoftwo}}} + {\@secondoftwo}} + {\@secondoftwo}} + +% {<csname1>}{<csname2>}{<true>}{<false>} + +\newcommand*{\ifcsstrequal}[2]{% + \ifcsundef{#1} + {\@secondoftwo} + {\ifcsundef{#2} + {\@secondoftwo} + {\expandafter\ifdefstrequal + \csname#1\expandafter\endcsname + \csname#2\endcsname}}} + +% {<cstoken>}{<string>}{<true>}{<false>} + +\newrobustcmd{\ifdefstring}[2]{% + \ifdefmacro{#1} + {\begingroup + \edef\etb@tempa{\expandafter\strip@prefix\meaning#1}% + \edef\etb@tempb{\detokenize{#2}}% + \ifx\etb@tempa\etb@tempb + \aftergroup\@firstoftwo + \else + \aftergroup\@secondoftwo + \fi + \endgroup} + {\@secondoftwo}} % {<csname>}{<string>}{<true>}{<false>} @@ -345,6 +372,79 @@ {\@secondoftwo} {\expandafter\ifdefstring\csname#1\endcsname{#2}}} +% {<cstoken>}{<true}{<false>} + +\newcommand{\ifdefcounter}[1]{\etb@ifcounter#1&} +\long\def\etb@ifcounter#1#2&{% + \ifx\count#1% + \expandafter\@secondoftwo + \else + \expandafter\etb@ifcounter@i\meaning#1:% + \fi} +\edef\etb@ifcounter@i#1:#2\fi{\noexpand\fi + \noexpand\etb@ifcounter@ii#1\string\count&} +\edef\etb@ifcounter@ii{% + \def\noexpand\etb@ifcounter@ii##1\string\count##2&} +\etb@ifcounter@ii{\ifblank{#1}} + +% {<csname>}{<true>}{<false>} + +\newcommand*{\ifcscounter}[1]{% + \ifcsdef{#1} + {\expandafter\ifdefcounter\csname#1\endcsname} + {\@secondoftwo}} + +% {<name>}{<true>}{<false>} + +\newcommand*{\ifltxcounter}[1]{% + \ifcsdef{c@#1} + {\expandafter\ifdefcounter\csname c@#1\endcsname} + {\@secondoftwo}} + +% {<cstoken>}{<true}{<false>} + +\newcommand{\ifdeflength}[1]{\etb@iflength#1&} +\long\def\etb@iflength#1#2&{% + \ifx\skip#1% + \expandafter\@secondoftwo + \else + \expandafter\etb@iflength@i\meaning#1:% + \fi} +\edef\etb@iflength@i#1:#2\fi{\noexpand\fi + \noexpand\etb@iflength@ii#1\string\skip&} +\edef\etb@iflength@ii{% + \def\noexpand\etb@iflength@ii##1\string\skip##2&} +\etb@iflength@ii{\ifblank{#1}} + +% {<csname>}{<true>}{<false>} + +\newcommand*{\ifcslength}[1]{% + \ifcsdef{#1} + {\expandafter\ifdeflength\csname#1\endcsname} + {\@secondoftwo}} + +% {<cstoken>}{<true}{<false>} + +\newcommand{\ifdefdimen}[1]{\etb@ifdimen#1&} +\long\def\etb@ifdimen#1#2&{% + \ifx\dimen#1% + \expandafter\@secondoftwo + \else + \expandafter\etb@ifdimen@i\meaning#1:% + \fi} +\edef\etb@ifdimen@i#1:#2\fi{\noexpand\fi + \noexpand\etb@ifdimen@ii#1\string\dimen&} +\edef\etb@ifdimen@ii{% + \def\noexpand\etb@ifdimen@ii##1\string\dimen##2&} +\etb@ifdimen@ii{\ifblank{#1}} + +% {<csname>}{<true>}{<false>} + +\newcommand*{\ifcsdimen}[1]{% + \ifcsdef{#1} + {\expandafter\ifdefdimen\csname#1\endcsname} + {\@secondoftwo}} + % {<string1>}{<string2>}{<true>}{<false>} \newrobustcmd{\ifstrequal}[2]{% @@ -1100,10 +1200,10 @@ % {<cstoken>} \newrobustcmd*{\robustify}[1]{% - \ifundef#1 + \ifundef{#1} {\etb@error{\string#1 undefined}\@eha} - {\ifdefmacro#1 - {\ifdefltxprotect#1 + {\ifdefmacro{#1} + {\ifdefltxprotect{#1} {\letcs\etb@resrvda{\expandafter\@gobble\string#1 }% \@tempswatrue} {\let\etb@resrvda#1% @@ -1147,12 +1247,12 @@ \long\def\etb@ifpatchable#1#2{% \endgroup \etb@dbg@init#1% - \ifundef#1 + \ifundef{#1} {\etb@dbg@fail{def}\@secondoftwo} {\etb@dbg@info{def}% - \ifdefmacro#1 + \ifdefmacro{#1} {\etb@dbg@info{mac}% - \etb@ifscanable#1 + \etb@ifscanable{#1} {\etb@ifhashcheck{#2} {\etb@dbg@info{tok}% \etb@ifpattern#1{#2} @@ -1166,19 +1266,19 @@ \long\def\etb@ifpatchable@i#1{% \endgroup \etb@dbg@init#1% - \ifundef#1 + \ifundef{#1} {\etb@dbg@fail{def}\@secondoftwo} {\etb@dbg@info{def}% - \ifdefmacro#1 + \ifdefmacro{#1} {\etb@dbg@info{mac}% - \ifdefparam#1 + \ifdefparam{#1} {\etb@dbg@info{prm}% - \etb@ifscanable#1 + \etb@ifscanable{#1} {\etb@dbg@info{tok}% \etb@dbg@info{pos}\@firstoftwo} {\etb@dbg@fail{tok}\@secondoftwo}} {\etb@dbg@info{prl}% - \ifdefprotected#1 + \ifdefprotected{#1} {\etb@dbg@info{pro}} {}% \etb@dbg@info{pos}\@firstoftwo}} @@ -1233,14 +1333,14 @@ \long\def\etb@hooktocmd#1#2#3{% \endgroup \etb@dbg@init#2% - \ifundef#2 + \ifundef{#2} {\etb@dbg@fail{def}\@secondoftwo} {\etb@dbg@info{def}% - \ifdefmacro#2 + \ifdefmacro{#2} {\etb@dbg@info{mac}% - \ifdefparam#2 + \ifdefparam{#2} {\etb@dbg@info{prm}% - \etb@ifscanable#2 + \etb@ifscanable{#2} {\etb@ifhashcheck{#3} {\etb@dbg@info{tok}% \etb@dbg@succ{ret}% @@ -1249,7 +1349,7 @@ {\etb@dbg@fail{hsh}\@secondoftwo}} {\etb@dbg@fail{tok}\@secondoftwo}} {\etb@dbg@info{prl}% - \ifdefprotected#2 + \ifdefprotected{#2} {\etb@dbg@info{pro}% \etb@dbg@succ{red}% \protected} @@ -1551,4 +1651,58 @@ \@afterenddocumenthook \etb@@end}} +% {<environment>}{<code>} + +\newrobustcmd{\AtBeginEnvironment}[1]{% + \csgappto{@begin@#1@hook}} + +\patchcmd\begin + {\csname #1\endcsname} + {\csuse{@begin@#1@hook}% + \csname #1\endcsname} + {} + {\etb@warning{% + Patching '\string\begin' failed!\MessageBreak + '\string\AtBeginEnvironment' will not work\@gobble}} + +% {<environment>}{<code>} + +\newrobustcmd{\AtEndEnvironment}[1]{% + \csgappto{@end@#1@hook}} + +\patchcmd\end + {\csname end#1\endcsname} + {\csuse{@end@#1@hook}% + \csname end#1\endcsname} + {} + {\etb@warning{% + Patching '\string\end' failed!\MessageBreak + '\string\AtEndEnvironment' will not work\@gobble}} + +% {<environment>}{<code>} + +\newrobustcmd{\BeforeBeginEnvironment}[1]{% + \csgappto{@beforebegin@#1@hook}} + +\pretocmd\begin + {\csuse{@beforebegin@#1@hook}} + {} + {\etb@warning{% + Patching '\string\begin' failed!\MessageBreak + '\string\BeforeBeginEnvironment' will not work\@gobble}} + +% {<environment>}{<code>} + +\newrobustcmd{\AfterEndEnvironment}[1]{% + \csgappto{@afterend@#1@hook}} + +\patchcmd\end + {\if@ignore} + {\csuse{@afterend@#1@hook}% + \if@ignore} + {} + {\etb@warning{% + Patching '\string\end' failed!\MessageBreak + '\string\AfterEndEnvironment' will not work\@gobble}} + \endinput |