summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/etoolbox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-09-09 00:13:06 +0000
committerKarl Berry <karl@freefriends.org>2010-09-09 00:13:06 +0000
commit0ce2c8b8193308d090a2c319fae8e6b6b348d62a (patch)
treee5235e981a65e99da22b0ac5cd14174cefacc373 /Master/texmf-dist/tex/latex/etoolbox
parente4ad19875bd975cc61b70dc09202285461aacca1 (diff)
etoolbox 2.0 (22aug10)
git-svn-id: svn://tug.org/texlive/trunk@19622 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.sty373
2 files changed, 208 insertions, 171 deletions
diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.def
index b898e8834d0..d3e0dbdf99d 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 1.9 2010/04/10 19:11:49 lehman stable $
+% $Id: etoolbox.def,v 2.0 2010/08/21 17:07:46 lehman stable $
\ProvidesFile{etoolbox.def}
-[\etb@rcsid $Id: etoolbox.def,v 1.9 2010/04/10 19:11:49 lehman stable $
+[\csname etb@rcsid\endcsname $Id: etoolbox.def,v 2.0 2010/08/21 17:07:46 lehman stable $
etoolbox debug messages]
\begingroup
@@ -14,7 +14,7 @@
\long\gdef\etb@dbg@trce#1{\typeout{%
[debug] tracing \string#1\on@line}}%
\long\gdef\etb@dbg@init#1{\typeout{%
- [debug] analyzing \detokenize\expandafter{\string#1}}}%
+ [debug] analyzing '\detokenize\expandafter{\string#1}'}}%
\gdef\etb@dbg@info#1{\typeout{%
[debug] ++ \csuse{etb@msg@i@#1}}}%
\gdef\etb@dbg@succ#1{\typeout{%
diff --git a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty
index 8c27ea8c3a2..d7dbd75ef39 100644
--- a/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty
+++ b/Master/texmf-dist/tex/latex/etoolbox/etoolbox.sty
@@ -1,4 +1,4 @@
-% $Id: etoolbox.sty,v 1.9 2010/04/10 19:11:49 lehman stable $
+% $Id: etoolbox.sty,v 2.0 2010/08/21 17:07:46 lehman stable $
% Copyright (c) 2007-2010 Philipp Lehman.
%
@@ -18,7 +18,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{etoolbox}
-[\etb@rcsid $Id: etoolbox.sty,v 1.9 2010/04/10 19:11:49 lehman stable $
+[\etb@rcsid $Id: etoolbox.sty,v 2.0 2010/08/21 17:07:46 lehman stable $
e-TeX tools for LaTeX]
\begingroup
@@ -35,15 +35,12 @@
\RequirePackage{etex}
-\edef\etb@restore{%
- \catcode\number`\&=\the\catcode`\&\relax
- \catcode\number`\|=\the\catcode`\|\relax
- \catcode\number`\:=\the\catcode`\:\relax
- \catcode\number`\-=\the\catcode`\-\relax
- \catcode\number`\==\the\catcode`\=\relax
- \catcode\number`\<=\the\catcode`\<\relax
- \catcode\number`\>=\the\catcode`\>\relax
-}
+\def\etb@catcodes{\do\&\do\|\do\:\do\-\do\=\do\<\do\>}
+\def\do#1{\catcode\number`#1=\the\catcode`#1\relax}
+\edef\etb@catcodes{\etb@catcodes}
+\let\do\noexpand
+\AtEndOfPackage{\etb@catcodes\undef\etb@catcodes}
+
\catcode`\&=3
\catcode`\|=3
\@makeother\:
@@ -52,10 +49,6 @@
\@makeother\<
\@makeother\>
-\AtEndOfPackage{%
- \etb@restore
- \undef\etb@restore}
-
\protected\def\etb@error{\PackageError{etoolbox}}
\protected\def\etb@info{\PackageInfo{etoolbox}}
\newcount\etb@tempcnta
@@ -63,12 +56,10 @@
% {<cstoken>}[<arguments>][<optarg default>]{<definition>}
\newcommand*{\newrobustcmd}{}
-\protected\def\newrobustcmd{%
- \@ifstar
- {\let\l@ngrel@x\relax\etb@new@command}
- {\let\l@ngrel@x\long\etb@new@command}}
+\protected\def\newrobustcmd{\@star@or@long\etb@new@command}
\def\etb@new@command#1{\@testopt{\etb@newcommand#1}0}
+
\def\etb@newcommand#1[#2]{%
\@ifnextchar[%]
{\etb@xargdef#1[#2]}
@@ -78,6 +69,7 @@
\protected\def\l@ngrel@x{\protected\long}%
\fi
\@argdef#1[#2]}}
+
\long\def\etb@xargdef#1[#2][#3]#4{%
\@ifdefinable#1{%
\expandafter\protected
@@ -90,17 +82,10 @@
% {<cstoken>}[<arguments>][<optarg default>]{<definition>}
-\newrobustcmd*{\renewrobustcmd}{%
- \@ifstar
- {\let\l@ngrel@x\protected\etb@renew@command}
- {\def\l@ngrel@x{\protected\long}\etb@renew@command}}
+\newrobustcmd*{\renewrobustcmd}{\@star@or@long\etb@renew@command}
\def\etb@renew@command#1{%
- \begingroup
- \escapechar\m@ne
- \xdef\@gtempa{{\string#1}}%
- \endgroup
- \expandafter\@ifundefined\@gtempa
+ \ifundef#1
{\etb@error{\string#1 undefined}\@ehc}
{}%
\let\@ifdefinable\@rc@ifdefinable
@@ -108,24 +93,23 @@
% {<cstoken>}[<arguments>][<optarg default>]{<definition>}
-\newrobustcmd*{\providerobustcmd}{%
- \@ifstar
- {\let\l@ngrel@x\protected\etb@provide@command}
- {\def\l@ngrel@x{\protected\long}\etb@provide@command}}
+\newrobustcmd*{\providerobustcmd}{\@star@or@long\etb@provide@command}
\def\etb@provide@command#1{%
- \begingroup
- \escapechar\m@ne
- \xdef\@gtempa{{\string#1}}%
- \endgroup
- \expandafter\@ifundefined\@gtempa
+ \ifundef#1
{\def\reserved@a{\etb@new@command#1}}
{\def\reserved@a{\etb@renew@command\reserved@a}}%
- \reserved@a}%
+ \reserved@a}
+
+% {<csname>}
+
+\newrobustcmd*{\csshow}[1]{%
+ \begingroup\expandafter\endgroup
+ \expandafter\show\csname#1\endcsname}
% {<cstoken>}{<true>}{<false>}
-\newcommand*{\ifdef}[1]{%
+\newcommand{\ifdef}[1]{%
\ifdefined#1%
\expandafter\@firstoftwo
\else
@@ -134,7 +118,7 @@
% {<cstoken>}{<true>}{<false>}
-\newcommand*{\ifundef}[1]{%
+\newcommand{\ifundef}[1]{%
\ifdefined#1%
\ifx#1\relax
\expandafter\expandafter
@@ -173,8 +157,8 @@
% {<cstoken>}{<true}{<false>}
-\newcommand*{\ifdefmacro}{}
-\edef\ifdefmacro#1{%
+\newcommand{\ifdefmacro}{}
+\long\edef\ifdefmacro#1{%
\noexpand\expandafter\noexpand\etb@ifdefmacro
\noexpand\meaning#1\detokenize{macro}:&}
\edef\etb@ifdefmacro{%
@@ -190,11 +174,11 @@
% {<cstoken>}{<true}{<false>}
-\newcommand*{\ifdefprefix}[1]{%
- \ifdefmacro{#1}
- {\etb@ifdefprefix{#1}}
+\newcommand{\ifdefprefix}[1]{%
+ \ifdefmacro#1
+ {\etb@ifdefprefix#1}
{\@secondoftwo}}
-\edef\etb@ifdefprefix#1{%
+\long\edef\etb@ifdefprefix#1{%
\noexpand\expandafter\noexpand\etb@ifdefprefix@i
\noexpand\meaning#1\detokenize{macro}:&}
\edef\etb@ifdefprefix@i{%
@@ -210,8 +194,8 @@
% {<cstoken>}{<true}{<false>}
-\newcommand*{\ifdefparam}{}
-\edef\ifdefparam#1{%
+\newcommand{\ifdefparam}{}
+\long\edef\ifdefparam#1{%
\noexpand\expandafter\noexpand\etb@ifdefparam
\noexpand\meaning#1\detokenize{macro}:->&}
\edef\etb@ifdefparam{%
@@ -227,8 +211,8 @@
% {<cstoken>}{<true}{<false>}
-\newcommand*{\ifdefprotected}{}
-\edef\ifdefprotected#1{%
+\newcommand{\ifdefprotected}{}
+\long\edef\ifdefprotected#1{%
\noexpand\expandafter\noexpand\etb@ifdefprotected
\noexpand\meaning#1\string\protected&}
\edef\etb@ifdefprotected{%
@@ -244,7 +228,7 @@
% {<cstoken>}{<true}{<false>}
-\newrobustcmd*{\ifdefltxprotect}[1]{%
+\newrobustcmd{\ifdefltxprotect}[1]{%
\begingroup
\edef\etb@resrvda{%
\noexpand\protect\expandafter\noexpand
@@ -264,12 +248,14 @@
% {<cstoken>}{<true>}{<false>}
-\newcommand*{\ifdefempty}[1]{%
- \ifundef{#1}
+\newcommand{\ifdefempty}[1]{%
+ \ifundef#1
{\@secondoftwo}
- {\ifdefparam{#1}
- {\@secondoftwo}
- {\etb@ifdefempty#1}}}
+ {\ifdefmacro#1
+ {\ifdefparam#1
+ {\@secondoftwo}
+ {\etb@ifdefempty#1}}
+ {\@secondoftwo}}}
\def\etb@ifdefempty#1{%
\expandafter\expandafter
@@ -289,17 +275,19 @@
% {<cstoken>}{<true>}{<false>}
-\newcommand*{\ifdefvoid}[1]{%
- \ifundef{#1}
+\newcommand{\ifdefvoid}[1]{%
+ \ifundef#1
{\@firstoftwo}
- {\ifdefparam{#1}
- {\@secondoftwo}
- {\etb@ifdefempty#1}}}
+ {\ifdefmacro#1
+ {\ifdefparam#1
+ {\@secondoftwo}
+ {\etb@ifdefempty#1}}
+ {\@secondoftwo}}}
% {<csname>}{<true>}{<false>}
\newcommand*{\ifcsvoid}[1]{%
- \ifcsundef{#1}%
+ \ifcsundef{#1}
{\@firstoftwo}
{\expandafter\ifdefparam\csname#1\endcsname
{\@secondoftwo}
@@ -307,12 +295,12 @@
% {<cstoken1>}{<cstoken2>}{<true>}{<false>}
-\newcommand*{\ifdefequal}[2]{%
- \ifundef{#1}
+\newcommand{\ifdefequal}[2]{%
+ \ifundef#1
{\@secondoftwo}
- {\ifundef{#2}
+ {\ifundef#2
{\@secondoftwo}
- {\ifx#1#2%
+ {\ifx#1#2
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
@@ -336,22 +324,24 @@
% {<cstoken>}{<string>}{<true>}{<false>}
\newrobustcmd{\ifdefstring}[2]{%
- \ifundef{#1}
+ \ifundef#1
{\@secondoftwo}
- {\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}}
+ {\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>}
\newrobustcmd{\ifcsstring}[2]{%
- \ifcsundef{#1}%
+ \ifcsundef{#1}
{\@secondoftwo}
{\expandafter\ifdefstring\csname#1\endcsname{#2}}}
@@ -437,7 +427,7 @@
% {<expr>}{<true>}{<false>}
-\newcommand*{\ifboolexpe}[1]{%
+\newcommand{\ifboolexpe}[1]{%
\etb@be@beg\etb@be@bgroup#1(&\etb@be@end}
\let\etb@be@true\@empty
@@ -456,21 +446,21 @@
\expandafter\@firstoftwo
\fi}
-\def\etb@be@bgroup#1(#2&{%
+\long\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&{%
+\long\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&{%
+\long\def\etb@be@and#1and#2&{%
\etb@be@or#1or&%
\ifblank{#2}
{}
@@ -483,7 +473,7 @@
\ifnum\numexpr\z@
\etb@be@and#2&}}
-\def\etb@be@or#1or#2&{%
+\long\def\etb@be@or#1or#2&{%
\etb@be@not#1not&%
\ifblank{#2}
{}
@@ -498,7 +488,7 @@
\ifnum\numexpr\z@}%
\etb@be@or#2&}}
-\def\etb@be@not#1not#2&{%
+\long\def\etb@be@not#1not#2&{%
\etb@be@togl#1togl&%
\ifblank{#2}
{}
@@ -511,25 +501,25 @@
{\unless\ifnum\numexpr\z@}%
\etb@be@not#2&}}
-\def\etb@be@togl#1togl#2&{%
+\long\def\etb@be@togl#1togl#2&{%
\etb@be@bool#1bool&%
\ifblank{#2}
{}
{\etb@be@togl@i#2&}}
-\def\etb@be@togl@i#1#2&{%
+\long\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&{%
+\long\def\etb@be@bool#1bool#2&{%
\etb@be@test#1test&%
\ifblank{#2}
{}
{\etb@be@bool@i#2&}}
-\def\etb@be@bool@i#1#2&{%
+\long\def\etb@be@bool@i#1#2&{%
\ifcsundef{if#1}
{\etb@be@err{Boolean '#1' undefined}{}}
{\csname if#1\endcsname
@@ -538,7 +528,7 @@
\fi}%
\etb@be@bool#2&}
-\def\etb@be@test#1test#2&{%
+\long\def\etb@be@test#1test#2&{%
\ifblank{#1}
{}
{\etb@be@err{The invalid part is: '\detokenize{#1}'}{}}%
@@ -546,11 +536,11 @@
{}
{\etb@be@test@i#2&}}
-\def\etb@be@test@i#1#2&{%
+\long\def\etb@be@test@i#1#2&{%
#1\etb@be@true\etb@be@false
\etb@be@test#2&}
-\def\etb@be@err#1#2{%
+\long\def\etb@be@err#1#2{%
\expandafter\ifnum\the\numexpr
\expandafter\ifnum\the\currentiftype=-3
\expandafter\thr@@
@@ -568,9 +558,9 @@
% {<expr>}{<true>}{<false>}
-\newrobustcmd*{\ifboolexpr}[1]{\etb@boolexpr{#1}}
+\newrobustcmd{\ifboolexpr}[1]{\etb@boolexpr{#1}}
-\def\etb@boolexpr#1{%
+\long\def\etb@boolexpr#1{%
\begingroup
\let\etb@br@neg\@firstoftwo
\etb@tempcnta\z@
@@ -597,27 +587,27 @@
\def\etb@br@true{%
\advance\etb@tempcnta\etb@br@neg\z@\m@ne
- \let\etb@br@neg\@firstoftwo}%
+ \let\etb@br@neg\@firstoftwo}
\def\etb@br@false{%
\advance\etb@tempcnta\etb@br@neg\m@ne\z@
- \let\etb@br@neg\@firstoftwo}%
+ \let\etb@br@neg\@firstoftwo}
-\def\etb@br@bgroup#1(#2&{%
+\long\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&{%
+\long\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&{%
+\long\def\etb@br@and#1and#2&{%
\etb@br@or#1or&%
\ifblank{#2}
{}
@@ -628,7 +618,7 @@
\fi
\etb@br@and#2&}}
-\def\etb@br@or#1or#2&{%
+\long\def\etb@br@or#1or#2&{%
\etb@br@not#1not&%
\ifblank{#2}
{}
@@ -639,36 +629,34 @@
\fi
\etb@br@or#2&}}
-\def\etb@br@not#1not#2&{%
+\long\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&{%
+\long\def\etb@br@togl#1togl#2&{%
\etb@br@bool#1bool&%
\ifblank{#2}
{}
{\etb@br@togl@i#2&}}
-\def\etb@br@togl@i#1#2&{%
+\long\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@err@expr{Toggle '#1' undefined}\etb@br@false}%
\etb@br@togl#2&}
-\def\etb@br@bool#1bool#2&{%
+\long\def\etb@br@bool#1bool#2&{%
\etb@br@test#1test&%
\ifblank{#2}
{}
{\etb@br@bool@i#2&}}
-\def\etb@br@bool@i#1#2&{%
+\long\def\etb@br@bool@i#1#2&{%
\ifcsundef{if#1}
- {\etb@err@expr{Boolean '#1' undefined}%
- \etb@br@false}
+ {\etb@err@expr{Boolean '#1' undefined}\etb@br@false}
{\csname if#1\endcsname
\etb@br@true
\else
@@ -676,7 +664,7 @@
\fi}%
\etb@br@bool#2&}
-\def\etb@br@test#1test#2&{%
+\long\def\etb@br@test#1test#2&{%
\ifblank{#1}
{}
{\etb@err@expr{The invalid part is: '\detokenize{#1}'}}%
@@ -684,7 +672,7 @@
{}
{\etb@br@test@i#2&}}
-\def\etb@br@test@i#1#2&{%
+\long\def\etb@br@test@i#1#2&{%
\ignorespaces#1\etb@br@true\etb@br@false
\etb@br@test#2&}
@@ -695,23 +683,23 @@
% {<expr>}{<code>}
-\newrobustcmd*{\whileboolexpr}[2]{%
+\newrobustcmd{\whileboolexpr}[2]{%
\etb@boolexpr{#1}{#2\whileboolexpr{#1}{#2}}{}}
% {<expr>}{<code>}
-\newrobustcmd*{\unlessboolexpr}[2]{%
+\newrobustcmd{\unlessboolexpr}[2]{%
\etb@boolexpr{#1}{}{#2\unlessboolexpr{#1}{#2}}}
% {<cstoken>}
-\newcommand*{\expandonce}[1]{%
+\newcommand{\expandonce}[1]{%
\unexpanded\expandafter{#1}}
% {<csname>}
\newcommand*{\csexpandonce}[1]{%
- \expandafter\expandonce\csname #1\endcsname}
+ \expandafter\expandonce\csname#1\endcsname}
% {<code>}
@@ -750,12 +738,12 @@
% {<csname>}{<cstoken>}
-\newrobustcmd*{\cslet}[2]{%
+\newrobustcmd{\cslet}[2]{%
\expandafter\let\csname#1\endcsname#2}
% {<cstoken>}{<csname>}
-\newrobustcmd*{\letcs}[2]{%
+\newrobustcmd{\letcs}[2]{%
\ifcsdef{#2}
{\expandafter\let\expandafter#1\csname#2\endcsname}
{\undef#1}}
@@ -765,8 +753,8 @@
\newrobustcmd*{\csletcs}[2]{%
\ifcsdef{#2}
{\expandafter\let
- \csname#1\expandafter\endcsname
- \csname#2\endcsname}
+ \csname#1\expandafter\endcsname
+ \csname#2\endcsname}
{\csundef{#1}}}
% {<csname>}
@@ -778,7 +766,7 @@
% {<cstoken>}
-\newrobustcmd*{\undef}[1]{\let#1\etb@undefined}
+\newrobustcmd{\undef}[1]{\let#1\etb@undefined}
% {<csname>}
@@ -1082,7 +1070,7 @@
% {<cstoken>}{<search>}{<true}{<false>}
-\protected\def\etb@ifpattern#1#2{%
+\protected\long\def\etb@ifpattern#1#2{%
\begingroup
\edef\etb@resrvda{%
\def\noexpand\etb@resrvda####1\detokenize{#2}####2&{%
@@ -1094,7 +1082,7 @@
% {<string>}{<true}{<false>}
-\protected\def\etb@ifhashcheck#1{%
+\protected\long\def\etb@ifhashcheck#1{%
\begingroup
\edef\etb@resrvda{\detokenize{#1}}%
\expandafter\endgroup
@@ -1112,10 +1100,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@tempa{\expandafter\@gobble\string#1 }%
\@tempswatrue}
{\let\etb@tempa#1%
@@ -1156,18 +1144,18 @@
\@makeother\#%
\@ifstar\etb@ifpatchable@i\etb@ifpatchable}
-\def\etb@ifpatchable#1#2{%
+\long\def\etb@ifpatchable#1#2{%
\endgroup
- \etb@dbg@init{#1}%
- \ifundef{#1}
+ \etb@dbg@init#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}
+ \etb@ifpattern#1{#2}
{\etb@dbg@info{pat}%
\etb@dbg@info{pos}\@firstoftwo}
{\etb@dbg@fail{pat}\@secondoftwo}}
@@ -1175,22 +1163,22 @@
{\etb@dbg@fail{tok}\@secondoftwo}}
{\etb@dbg@fail{mac}\@secondoftwo}}}
-\def\etb@ifpatchable@i#1{%
+\long\def\etb@ifpatchable@i#1{%
\endgroup
- \etb@dbg@init{#1}%
- \ifundef{#1}
+ \etb@dbg@init#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}}
@@ -1205,12 +1193,12 @@
\etb@patchcmd}
\newcommand{\etb@patchcmd}[4][########1]{%
- \etb@ifpatchable{#2}{#3}
+ \etb@ifpatchable#2{#3}
{\etb@dbg@succ{ret}%
\begingroup
\edef\etb@resrvda{%
\def\noexpand\etb@resrvda####1\detokenize{macro:}####2->####3&{%
- #1\def\string#2####2{\noexpand\etb@resrvdb####3&}}%
+ #1\csdef{\expandafter\@gobble\string#2}####2{\noexpand\etb@resrvdb####3&}}%
\def\noexpand\etb@resrvdb####1\detokenize{#3}####2&{%
####1\detokenize{#4}####2}%
\edef\noexpand\etb@resrvda{%
@@ -1227,7 +1215,7 @@
\catcode\number`\@=\the\catcode`\@\relax}%
\etb@resrvda}
-% {<cstoken>}{<code>}
+% {<cstoken>}{<code>}{<success>}{<failure>}
\newrobustcmd*{\apptocmd}{%
\etb@dbg@trce\apptocmd
@@ -1243,24 +1231,24 @@
\long\def\etb@hooktocmd#1#2#3{%
\endgroup
- \etb@dbg@init{#2}%
- \ifundef{#2}
+ \etb@dbg@init#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}%
- \etb@hooktocmd@i{#1}{#2}{#3}%
+ \etb@hooktocmd@i#1#2{#3}%
\@firstoftwo}
{\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}
@@ -1273,7 +1261,7 @@
\begingroup
\edef\etb@resrvda{%
\def\noexpand\etb@resrvda####1\detokenize{macro}:####2->####3&{%
- ####1\def\string#2####2{#1{####3}{\detokenize{#3}}}}%
+ ####1\csdef{\expandafter\@gobble\string#2}####2{#1{####3}{\detokenize{#3}}}}%
\edef\noexpand\etb@resrvda{%
\noexpand\etb@resrvda\meaning#2&}}%
\etb@resrvda
@@ -1371,30 +1359,55 @@
\def\etb@ifr@brk#1\relax{\@secondoftwo}
-% {<command>}{<separator>}
+% <*>{<command>}{<separator>}
-\newrobustcmd*{\DeclareListParser}[2]{%
- \@ifdefinable#1{%
- \expandafter\expandafter\expandafter\etb@defparser
- \expandafter\expandafter\expandafter{%
- \expandafter\@gobble\string#1}{#2}}}
+\newrobustcmd*{\DeclareListParser}{%
+ \@ifstar
+ {\etb@defparser\etb@defparser@arg}
+ {\etb@defparser\etb@defparser@do}}
+
+\def\etb@defparser#1#2#3{%
+ \@ifdefinable#2{#1{#2}{#3}}}
-\def\etb@defparser#1#2{%
+\def\etb@defparser@do#1#2{%
\begingroup
\edef\@tempa{\endgroup
- \long\csdef{#1}####1{\expandafter\noexpand
- \csname etb@lst@#1\endcsname####1\noexpand#2&}%
- \long\csdef{etb@lst@#1}####1\noexpand#2####2&{%
- \noexpand\ifblank{####1}
- {}
- {\noexpand\etb@doitem####1&}%
+ \long\def\noexpand#1####1{%
+ \expandafter\noexpand
+ \csname etb@lst@\expandafter\@gobble\string#1\endcsname
+ \space####1\noexpand#2&}%
+ \long\csdef{etb@lst@\expandafter\@gobble\string#1}####1\noexpand#2####2&{%
+ \noexpand\etb@listitem\noexpand\do{####1}%
\noexpand\ifblank{####2}
{\noexpand\listbreak}
{\expandafter\noexpand
- \csname etb@lst@#1\endcsname####2}&}}%
+ \csname etb@lst@\expandafter\@gobble\string#1\endcsname
+ \space####2}&}}%
+ \@tempa}
+
+\def\etb@defparser@arg#1#2{%
+ \begingroup
+ \edef\@tempa{\endgroup
+ \long\def\noexpand#1####1####2{%
+ \expandafter\noexpand
+ \csname etb@lst@\expandafter\@gobble\string#1\endcsname
+ {####1}\space####2\noexpand#2&}%
+ \long\csdef{etb@lst@\expandafter\@gobble\string#1}####1####2\noexpand#2####3&{%
+ \noexpand\etb@listitem{####1}{####2}%
+ \noexpand\ifblank{####3}
+ {\noexpand\listbreak}
+ {\expandafter\noexpand
+ \csname etb@lst@\expandafter\@gobble\string#1\endcsname
+ {####1}\space####3}&}}%
\@tempa}
-\long\def\etb@doitem#1#2&{\do{#1#2}}
+\long\def\etb@listitem#1#2{%
+ \ifblank{#2}
+ {}
+ {\expandafter\etb@listitem@i
+ \expandafter{\@firstofone#2}{#1}}}
+\long\def\etb@listitem@i#1#2{#2{#1}}
+
\newcommand*{\listbreak}{}
\long\def\listbreak#1&{}
@@ -1402,6 +1415,10 @@
\DeclareListParser{\docsvlist}{,}
+% {<handler>}{<item1>,<item2>,...} => <handler>{<item1>}<handler>{<item2>}...
+
+\DeclareListParser*{\forcsvlist}{,}
+
% {<listmacro>}{<string>}
\newrobustcmd{\listadd}[2]{%
@@ -1452,17 +1469,35 @@
\edef\etb@tempa{\endgroup\ifinlistcs{#1}}%
\etb@tempa}
-% {<listmacro>} => \do{<item1>}\do{<item2>}...
+% {<handler>}{<listmacro>} => <handler>{<item1>}<handler>{<item2>}...
-\newcommand*{\dolistloop}[1]{%
- \expandafter\etb@listloop\expandafter{#1}}
+\newcommand*{\forlistloop}[2]{%
+ \expandafter\etb@forlistloop\expandafter{#2}{#1}}
-\DeclareListParser{\etb@listloop}{|}
+\long\def\etb@forlistloop#1#2{\etb@forlistloop@i{#2}#1|&}
+
+\long\def\etb@forlistloop@i#1#2|#3&{%
+ \ifblank{#2}
+ {}
+ {#1{#2}}%
+ \ifblank{#3}
+ {\listbreak}
+ {\etb@forlistloop@i{#1}#3}%
+ &}
+
+% {<handler>}{<listcsname>} => <handler>{<item1>}<handler>{<item2>}...
+
+\newcommand*{\forlistcsloop}[2]{%
+ \expandafter\expandafter\expandafter\etb@forlistloop
+ \expandafter\expandafter\expandafter{\csname#2\endcsname}{#1}}
+
+% {<listmacro>} => \do{<item1>}\do{<item2>}...
+
+\newcommand*{\dolistloop}{\forlistloop\do}
% {<listcsname>} => \do{<item1>}\do{<item2>}...
-\newcommand*{\dolistcsloop}[1]{%
- \expandafter\dolistloop\csname#1\endcsname}
+\newcommand*{\dolistcsloop}{\forlistcsloop\do}
% {<code>}
@@ -1494,6 +1529,8 @@
\undef\@afterendpreamblehook
\ignorespaces}
+\AtEndDocument{\let\AfterEndPreamble\@gobble}
+
% {<code>}
\newrobustcmd*{\AfterEndDocument}{\gappto\@afterenddocumenthook}