summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/catoptions
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-10-18 22:38:52 +0000
committerKarl Berry <karl@freefriends.org>2012-10-18 22:38:52 +0000
commitdfee8c21fa1b6c00891bec9d201ef488c400bdd5 (patch)
tree3ef2bdc3ba236e0fb3044a001a799c6be4a73fc7 /Master/texmf-dist/tex/latex/catoptions
parent27f8bac5dc1835a33e53fda37a0f7a6204582a12 (diff)
catoptions (15oct12)
git-svn-id: svn://tug.org/texlive/trunk@28015 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/catoptions')
-rw-r--r--Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg4
-rw-r--r--Master/texmf-dist/tex/latex/catoptions/catoptions.sty478
2 files changed, 271 insertions, 211 deletions
diff --git a/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg b/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg
index 538fac72380..dd1a6efd158 100644
--- a/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg
+++ b/Master/texmf-dist/tex/latex/catoptions/catoptions-guide.cfg
@@ -1,8 +1,8 @@
\ProvidesFile{catoptions-guide.cfg}%
- [2011/12/17 v0.2.7b Configuration file for catoptions-guide.tex (AM)]
+ [2012/10/14 v0.2.7e Configuration file for catoptions-guide.tex (AM)]
\cptloadpackages{%
- xwatermark|printwatermark;
+ n-xwatermark|printwatermark;
array;
colortbl;
ltablex;
diff --git a/Master/texmf-dist/tex/latex/catoptions/catoptions.sty b/Master/texmf-dist/tex/latex/catoptions/catoptions.sty
index b5cd097fc37..4f112b72f81 100644
--- a/Master/texmf-dist/tex/latex/catoptions/catoptions.sty
+++ b/Master/texmf-dist/tex/latex/catoptions/catoptions.sty
@@ -1,5 +1,5 @@
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
-% This is 'catoptions' package, version 0.2.7d, 2012/08/02. %
+% This is 'catoptions' package, version 0.2.7e, 2012/10/14. %
% %
% The catoptions package changes LaTeX package loading internals %
% so that all subsequently loaded packages can rely on having %
@@ -112,7 +112,7 @@
\chardef\active=13
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{catoptions}
- [2012/08/02 v0.2.7d Securing catcodes and parsing options (AM)]
+ [2012/10/14 v0.2.7e Securing catcodes and parsing options (AM)]
\ifcase%
\ifx\eTeXversion\cpt@undefined\z@pt\else
\ifnum\eTeXversion<\tw@\z@pt\else\@ne\fi\fi
@@ -133,8 +133,8 @@
\cptnewlet\cpt@nil\relax
\newcommand*\cpt@nnil{\cpt@nil}
\let\@iden\@firstofone
-\cptnewlet\iofii\@firstoftwo
-\cptnewlet\iiofii\@secondoftwo
+\def\cptiofii#1#2{#1}
+\def\cptiiofii#1#2{#2}
\@ifdefinable\ifforbreak{\newif\ifforbreak}
\cptnewlet\cpt@starorlong\@star@or@long
\cptnewlet\cpt@testopt\@testopt
@@ -155,7 +155,7 @@
}
\newcommand*\cpt@for@nil{\cpt@for@nil}
% Simple, 1-dimensional comma loop. \forbreak can be used to break
-% out of the loop. \do may appear in #1; so we can't use \do as delimiter:
+% out of the loop. \do may appear in #1; so we can't use \do as the delimiter:
\protected\def\cptfor#1\dofor#2{%
\def\cpt@fordo##1,{\cpt@for@a,\cpt@fordo{##1}{#2}}%
\edef\reserved@a{\cptcommanormalize{#1}}%
@@ -171,7 +171,7 @@
\edef\reserved@a{\unexpanded{#3}}%
\ifx\reserved@a\cpt@for@nil\expandafter\@gobble\else
\expandafter\@iden\fi{%
- \ifforbreak\expandafter\iofii\else\expandafter\iiofii\fi
+ \ifforbreak\expandafter\cptiofii\else\expandafter\cptiiofii\fi
{\def\reserved@a##1\cpt@for@nil#1{}\reserved@a}{#4#2}%
}%
}
@@ -184,7 +184,7 @@
}
\def\cpt@foreachmeer@a#1,#2\meer@nil#3{%
\expandafter\ifx\cpt@car#1\car@nil\cpt@nnil
- \expandafter\iofii\else\expandafter\iiofii\fi
+ \expandafter\cptiofii\else\expandafter\cptiiofii\fi
{}{#3{#1}\cpt@foreachmeer@a#2\meer@nil{#3}}%
}
% Unique \chardef'd token:
@@ -239,12 +239,12 @@
\newcommand*\cpt@quark{\@gobble\cpt@quark}
\newcommand\ifxTF[2]{%
\ifblankTF{#1}{%
- \ifblankTF{#2}\iofii\iiofii
+ \ifblankTF{#2}\cptiofii\cptiiofii
}{%
- \ifblankTF{#2}\iiofii{%
+ \ifblankTF{#2}\cptiiofii{%
\expandafter\ifblankTF\expandafter{\@gobble#1}{%
\expandafter\ifblankTF\expandafter{\@gobble#2}{%
- \ifx#1#2\expandafter\iofii\else\expandafter\iiofii\fi
+ \ifx#1#2\expandafter\cptiofii\else\expandafter\cptiiofii\fi
}{%
\cpt@notonetokenerr{#2}%
}%
@@ -254,33 +254,32 @@
}%
}%
}
-\newcommand\ifxFT[2]{\ifxTF{#1}{#2}\iiofii\iofii}
+\newcommand\ifxFT[2]{\ifxTF{#1}{#2}\cptiiofii\cptiofii}
\def\cpt@ifcseq@#1#2\cpt@ifcseq@nil{\expandafter#1}
\newcommand\ifcseqTF[2]{%
\csname @\expandafter\expandafter\expandafter
\ifx\cpt@ifcseq@#1\batchmode\cpt@ifcseq@nil\cpt@car#2\noboundary\car@nil
first\else second\fi oftwo\endcsname
}
-\newcommand\ifcseqFT[2]{\ifcseqTF{#1}{#2}\iiofii\iofii}
+\newcommand\ifcseqFT[2]{\ifcseqTF{#1}{#2}\cptiiofii\cptiofii}
\newcommand*\ifxcseqTF[2]{%
\ifcseqTF{#1}{#2}{%
- \iofii
+ \cptiofii
}{%
\expandafter\cptswapbracefirst\expandafter{#1}%
{\expandafter\ifstrcmpTF\expandafter{#2}}%
- \iofii\iiofii
+ \cptiofii\cptiiofii
}%
}
-\newcommand\ifnullTF[3]{%
- \romannumeral\iffalse{\fi\expandafter\@secondoftwo\expandafter
- {\expandafter{\string#1}\expandafter\@secondoftwo\string}%
- \expandafter\@firstoftwo\expandafter{\iffalse}\fi0 #3}{0 #2}%
+\newcommand\ifnullTF[1]{%
+ \ifcat$\detokenize{#1}$\expandafter\@firstoftwo
+ \else\expandafter\@secondoftwo\fi
}
-\newcommand\ifnullFT[1]{\ifnullTF{#1}\iiofii\iofii}
+\newcommand\ifnullFT[1]{\ifnullTF{#1}\cptiiofii\cptiofii}
\newcommand\ifblankTF[1]{%
\expandafter\ifnullTF\expandafter{\@gobble#1.}%
}
-\newcommand\ifblankFT[1]{\ifblankTF{#1}\iiofii\iofii}
+\newcommand\ifblankFT[1]{\ifblankTF{#1}\cptiiofii\cptiofii}
\let\then\iffalse
\let\dolacus\iffalse
\@ifdefinable\iflacus\relax
@@ -289,10 +288,10 @@
}
\newcommand\ifbracedTF[3]{%
\romannumeral\expandafter\@secondoftwo\expandafter{\expandafter
- {\string#1.}\expandafter\@firstoftwo\expandafter{\iffalse}\fi
+ {\string#1.}\expandafter\cptiofii\expandafter{\iffalse}\fi
0 #2}{0 #3}%
}
-\newcommand\ifbracedFT[1]{\ifbracedTF{#1}\iiofii\iofii}
+\newcommand\ifbracedFT[1]{\ifbracedTF{#1}\cptiiofii\cptiofii}
\newcommand\ifleadspaceTF[3]{%
\romannumeral\csname
@\ifnullTF{#1}{second}{\iffalse{\fi\cpt@ifleadspace.#1 }}%
@@ -311,7 +310,7 @@
}
\newcommand\cpt@iftrailspace[1]{%
\ifnullTF{#1}{%
- \expandafter\iiofii\iofii
+ \expandafter\cptiiofii\cptiofii
}{%
\ifleadspaceTF{#1}{%
\expandafter\ifnullTF\expandafter{\@gobblespace#1}{%
@@ -346,7 +345,7 @@
\usename{@\ifnum\cpt@pdfstrcmp{\detokenize{#1}}%
{\detokenize{#2}}=0first\else second\fi oftwo}%
}
-\newcommand\ifstrcmpFT[2]{\ifstrcmpTF{#1}{#2}\iiofii\iofii}
+\newcommand\ifstrcmpFT[2]{\ifstrcmpTF{#1}{#2}\cptiiofii\cptiofii}
\newcommand*\cpt@def@[3]{%
\ifcsdefinable#3\relax
\ifcat$\detokenize{#2}$\else\protected\fi
@@ -442,7 +441,7 @@
}%
}
\robust@def*\BeginOverlookWhiteSpace{%
- \pushnumber\cpt@overlooknr
+ \cptpushnumber\cpt@overlooknr
\ifnum\cpt@overlooknr>\@ne
\cpt@err{There is an unclosed
\string\BeginOverlookWhiteSpace}\@ehc
@@ -458,7 +457,7 @@
\undefcs\cpt@overlooknr
}
\robust@def*\BeginOverlookEndline{%
- \pushnumber\cpt@overlookendlinenr
+ \cptpushnumber\cpt@overlookendlinenr
\ifnum\cpt@overlookendlinenr>\@ne
\cpt@err{There is an unclosed
\string\BeginOverlookEndline}\@ehc
@@ -827,23 +826,17 @@
\ifcsndefTF{#1}{%
\usename{#1}%
}{%
- \let\relax\relax
\cpt@err{Command '\@backslashchar#1' undefined}\@ehc
}%
}
-
-% The following syntax is needed for calling \ifcondTF in \edef.
-\new@def\ifcondTF#1\endcond#2#3{%
- \romannumeral\csname @#1first\else second\fi oftwo\endcsname
- {0 #2}{0 #3}%
-}
-\new@def\ifcondFT#1\endcond#2#3{\ifcondTF#1\endcond{#3}{#2}}
+\new@def\ifcondTF#1\fi{\csname @#1first\else second\fi oftwo\endcsname}
+\new@def\ifcondFT#1\fi{\ifcondTF#1\fi}
\new@def*\ifcsnameTF#1{%
\ifblankTF{#1}\@secondoftwo{%
\usename{@\ifcsname#1\endcsname first\else second\fi oftwo}%
}%
}
-\new@def*\ifcsnameFT#1{\ifcsnameTF{#1}\iiofii\iofii}
+\new@def*\ifcsnameFT#1{\ifcsnameTF{#1}\cptiiofii\cptiofii}
\new@def*\ifnamedefTF#1{%
\ifcsnameTF{#1}{%
\usename{@\expandafter\ifx\csname#1\endcsname\relax
@@ -871,9 +864,9 @@
\cptpassexpanded{%
\endgroup
\ifcase#1\relax
- \ifdefboolTF{cpt@choicefd}\iofii\iiofii
+ \ifdefboolTF{cpt@choicefd}\cptiofii\cptiiofii
\or
- \ifdefboolTF{cpt@choicefd}\iiofii\iofii
+ \ifdefboolTF{cpt@choicefd}\cptiiofii\cptiofii
\else
\cpt@err{Invalid number '#1'}\noexpand\@ehc
\fi
@@ -1045,7 +1038,7 @@
\message{Run time: \the\pdfelapsedtime}%
}
\new@def*\ifdocstartedTF{%
- \ifdefTF\cpt@docstarted\iofii\iiofii
+ \ifdefTF\cpt@docstarted\cptiofii\cptiiofii
}
\long\def\@gobblethree#1#2#3{}
@@ -1411,14 +1404,14 @@
\new@def\oifblankTF#1{\expandafter\ifblankTF\expandafter{#1}}
\new@def\oifblankFT#1{\expandafter\ifblankFT\expandafter{#1}}
\new@def\xifblankTF#1{\cptexpandarg\ifblankTF{#1}}
-\new@def\xifblankFT#1{\xifblankTF{#1}\iiofii\iofii}
+\new@def\xifblankFT#1{\xifblankTF{#1}\cptiiofii\cptiofii}
\new@def*\ifdefTF#1{%
\ifblankTF{#1}\@secondoftwo{%
\usename{@\ifx#1\cpt@undefined second\else
\ifx#1\relax second\else first\fi\fi oftwo}%
}%
}
-\new@def*\ifdefFT#1{\ifdefTF{#1}\iiofii\iofii}
+\new@def*\ifdefFT#1{\ifdefTF{#1}\cptiiofii\cptiofii}
\new@def*\oifdefTF#1{\expandafter\ifdefTF\expandafter{#1}}
\new@def*\oifdefFT#1{\expandafter\ifdefFT\expandafter{#1}}
\new@def*\xifdefTF#1{\cptexpandarg\ifdefTF{#1}}
@@ -1436,7 +1429,7 @@
\aftercsname\ifdefTF{#1}%
}%
}
-\new@def*\ifcsndefFT#1{\ifcsndefTF{#1}\iiofii\iofii}
+\new@def*\ifcsndefFT#1{\ifcsndefTF{#1}\cptiiofii\cptiofii}
\new@def*\oifcsndefTF#1{\expandafter\ifcsndefTF\expandafter{#1}}
\new@def*\oifcsndefFT#1{\expandafter\ifcsndefFT\expandafter{#1}}
\new@def*\xifcsndefTF#1{\cptexpandarg\ifcsndefTF{#1}}
@@ -1460,7 +1453,7 @@
\@secondoftwo
}{%
\ifdefTF{#1}\@secondoftwo{%
- \ifcsndefTF{end\cptgobblescape#1}\iiofii\iofii
+ \ifcsndefTF{end\cptgobblescape#1}\cptiiofii\cptiofii
}%
}%
}
@@ -1481,10 +1474,7 @@
\new@def*\cpt@xtestopt#1#2#3{%
\cpt@xifbrack#1\\[\\{#2#1}{#2[{#3}]{#1}}%
}
-\new@def*\cpt@xifbrack#1[#2\\#3#{%
- \ifcat$\detokenize{#1#2}$\expandafter\@firstoftwo
- \else\expandafter\@secondoftwo\fi
-}
+\new@def*\cpt@xifbrack#1[#2\\#3#{\ifblankTF{#1#2}}
% Eg, \def\macroa{\cpt@newxtestopt\macrob{Mr.}}
% \def\macrob[#1]#2{#1 #2}
% \edef\testa{\expandafter\macroa\activespace{John Johnson}}
@@ -1498,7 +1488,7 @@
\ifstrcmpTF{#3}{[}{%
#1[%
}{%
- \ifsingletokenTF{#3}{%
+ \ifntypeTF{#3}{%
#1[#2]#3%
}{%
#1[#2]{#3}%
@@ -1561,8 +1551,8 @@
}%
}
\new@def*\cpt@fullleterr#1#2{%
- \simpleexpandarg\ifsingletokenTF{#1}{%
- \simpleexpandarg\ifsingletokenTF{#2}{}{%
+ \simpleexpandarg\ifntypeTF{#1}{%
+ \simpleexpandarg\ifntypeTF{#2}{}{%
\cpt@notonetokenerr{#2}%
}%
}{%
@@ -1643,9 +1633,10 @@
\cpt@ifdimen@a\cpt@ifdimen@a\cpt@ifdimen@b
\endgroup
-% #1 can be arbitrary number (\countdef'd or otherwise):
-\robust@def*\pushnumber#1{%
- \ifsingletokenTF{#1}{%
+% Argument #1 can be an arbitrary number (\countdef'd or otherwise).
+% Pushing is done globally.
+\robust@def*\cptpushnumber#1{%
+ \ifntypeTF{#1}{%
\ifdefTF{#1}{%
\ifcounterTF#1{%
\global\advance#1\@ne
@@ -1659,8 +1650,8 @@
\cpt@notonetokenerr{#1}%
}%
}
-\robust@def*\popnumber#1{%
- \ifsingletokenTF{#1}{%
+\robust@def*\cptpopnumber#1{%
+ \ifntypeTF{#1}{%
\ifdefTF{#1}{%
\ifnumcmpTF#1=\z@pt{%
\cpt@err{Counter or number '\string#1' is already 0}\@ehc
@@ -1681,30 +1672,39 @@
% #1: calling/base function to push
% #2: comma-separated state list (subsidiary functions) to push
% #3: arbitrary number
-\robust@def*\pushfunctions#1#2#3{%
- \pushnumber{#3}%
+
+\robust@def*\cptpushfunctions#1#2#3{%
\begingroup
- \edef\cpt@stack{\cptremovescape{#1}@stack}%
- \ifcsndefTF\cpt@stack{}{\csn@def\cpt@stack{}}%
- \toks@{}\toks1{}\escapechar92\relax
- % Using \csv@@loop or \csv@@parse here will bomb out,
- % because \pushfunctions is called within those loops:
+ \def\reserved@a##1##2\push@nil{%
+ \ifx\cptpushfunctions##2%
+ \cptpushnumber#3%
+ \else
+ \cpt@notonetokenerr{#3}%
+ \fi
+ }%
+ \reserved@a#3\cptpushfunctions\push@nil
+ \toks@{}\@temptokena{}\escapechar-1\relax
\let\xp\expandcsonce
- \cptfor#2\dofor{%
- \ifescapedTF{##1}{}{\cpt@notescapederr{##1}}%
- \edef\cpt@tempa{\noexpandcsn{\cptremovescape{##1}@\cptrm#3}}%
- \cptpassexpanded{%
+ \edef\cpt@stack{\string#1@cpt@stack}%
+ \ifcsndefTF\cpt@stack{}{\csn@def\cpt@stack{}}%
+ \def\\##1{%
+ \edef\cpt@tempa{\noexpandcsn{\string##1@cpt@\cptrm#3}}%
+ \cptexpanded{%
\toks@{\the\toks@\let\xp\cpt@tempa\noexpand##1}%
- \toks1{\the\toks1\let\noexpand##1\xp\cpt@tempa
+ \@temptokena{\the\@temptokena\let\noexpand##1\xp\cpt@tempa
\undefcs\xp\cpt@tempa}%
}%
}%
- \csn@xdef\cpt@stack{\the\toks1\cpt@nil{\expandcsnonce\cpt@stack}}%
+ #2%
+ \csn@xdef\cpt@stack{%
+ \the\@temptokena\noexpand\cpt@nil{\expandcsnonce\cpt@stack}%
+ }%
\expandafter\endgroup\the\toks@
}
+
% #1: calling/base function to pop
% #2: depth counter
-\robust@def*\popfunctions#1#2{%
+\robust@def*\cptpopfunctions#1#2{%
\ifdefTF{#2}{%
\ifnum#2=\z@pt
\cpt@err{Number '\string#2' is currently '0'}\@ehc
@@ -1713,7 +1713,7 @@
\cpt@err{Can't pop functions with unknown
\MsgBrk number \string#2}\@ehc
}%
- \edef\cpt@stack{\cptremovescape{#1}@stack}%
+ \edef\cpt@stack{\cptremovescape{#1}@cpt@stack}%
\ifcsndefTF\cpt@stack{%
\edef\reserved@a{\expandcsnonce\cpt@stack}%
\def\reserved@b##1\cpt@nil{##1\csn@gdef\cpt@stack}%
@@ -1722,7 +1722,7 @@
\cpt@err{Unknown stack for function \string#1}\@ehc
\@gobble
}%
- \popnumber{#2}%
+ \cptpopnumber{#2}%
}
\cptchardef\cpt@optionstacklimit=4
% #1: calling (base) function
@@ -1739,11 +1739,11 @@
\MsgBrk\noexpand\documentclass
}\@ehc
\fi
- \cptexpandargonce{\pushfunctions#1}{#2}{#3}%
+ \cptexpandargonce{\cptpushfunctions#1}{#2}{#3}%
}
% #1: calling/base function
% #2: state counter
-\robust@def*\cpt@popstate#1#2{\popfunctions{#1}{#2}}
+\robust@def*\cpt@popstate#1#2{\cptpopfunctions{#1}{#2}}
\robust@def*\cpt@stchoose#1#2#3#4{%
\ifdefboolTF{#1}{%
\ifmacroTF{#2}{%
@@ -1792,7 +1792,7 @@
% of this need. Calling \dofunclist is equivalent to defining
% a multi-parametered \do within \csv@do:
\robust@def*\cptdofunclist{%
- \pushnumber\dofunclistdepth
+ \cptpushnumber\dofunclistdepth
\begingroup
\edef\sav@do{\cptmakecs{sav@do@\cptrm\dofunclistdepth}}%
\expandafter\let\sav@do\do
@@ -1826,8 +1826,10 @@
% \cpt@loopcbk is meant for callbacks with hash characters.
% It can be defined outside \csv@do or \kv@do and called within
% \csv@do or \kv@do.
- \pushfunctions\cpt@listparse{\cpt@listdo,\curr@do,\cpt@loopcbk,%
- \ifcpt@useempty,\ifloopbreak,\cptdoremainder}\cpt@csvdepth
+ \cptpushfunctions\cpt@listparse{%
+ \\\cpt@listdo\\\curr@do\\\cpt@loopcbk
+ \\\ifcpt@useempty\\\ifloopbreak\\\cptdoremainder
+ }\cpt@csvdepth
\letcstocsn\curr@do{\if\cpt@inkv kv\else csv\fi @do}%
\ifdefTF\curr@do{}{%
\cpt@err{'\string\csv@do' or '\string\kv@do' is undefined}\@ehc
@@ -1857,7 +1859,7 @@
}%
\loopbreakfalse
\expandafter\cpt@listdo\expandafter.\cpt@csvarg#1\cpt@csvnil#1%
- \popfunctions\cpt@listparse\cpt@csvdepth
+ \cptpopfunctions\cpt@listparse\cpt@csvdepth
\ifnum\cpt@csvdepth=\z@pt
% So that these functions are defined before the loop is called:
\undefcs\csv@do\undefcs\kv@do\undefcs\dofunclistdepth
@@ -1865,7 +1867,7 @@
}
% #1=keyval list, #2=processor
\robust@def*\kv@@process#1#2{%
- \pushfunctions\kv@@process{\kv@do,\ifloopbreak,#2}\cpt@csvdepth
+ \cptpushfunctions\kv@@process{\\\kv@do\\\ifloopbreak\\#2}\cpt@csvdepth
\def\kv@do##1,{%
\defifxTF{##1}\cpt@nnil{}{%
\def\reserved@a####1={%
@@ -1890,10 +1892,10 @@
}%
\kv@@normalize{#1}%
\expandafter\kv@do\normalized@list,\cpt@nil,%
- \popfunctions\kv@@process\cpt@csvdepth
+ \cptpopfunctions\kv@@process\cpt@csvdepth
}
\robust@def*\cpt@setupuserdo#1{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\ifmacroTF{#1}{\let\user@do#1}{\cpt@notcserr{#1}}%
}{%
\cpt@notonetokenerr{#1}%
@@ -1916,9 +1918,10 @@
% #2: list
% #3: a one-parameter recurrent macro (eg, \do)
\robust@def*\cpt@indrisloop[#1]#2#3{%
- \pushfunctions\indrisloop{\indris@do,\indrisnr,%
- \iflastindris,\ifloopbreak,\user@do,\getnextindris,%
- \cptdoremainder}\cpt@csvdepth
+ \cptpushfunctions\indrisloop{%
+ \\\indris@do\\\indrisnr\\\iflastindris\\\ifloopbreak
+ \\\user@do\\\getnextindris\\\cptdoremainder
+ }\cpt@csvdepth
\advance\indrisdepth\@ne
\cpt@stchoose{cpt@st}{#2}\cpt@rsvda\indrisloop
\cpt@sttrue\cpt@csvnormalize[#1]\cpt@rsvda
@@ -1947,7 +1950,7 @@
}%
}%
\expandafter\indris@do\expandafter.\cpt@rsvda#1\cpt@nil#1\indris@nil
- \popfunctions\indrisloop\cpt@csvdepth
+ \cptpopfunctions\indrisloop\cpt@csvdepth
\advance\indrisdepth\m@one
}
@@ -1981,8 +1984,9 @@
}
\robust@def*\indristloop#1#2{\cpt@testst\cpt@indristloop}
\robust@def*\cpt@indristloop#1#2{%
- \pushfunctions\indristloop{\user@do,\indrisnr,\iflastindris,
- \ifloopbreak}\cpt@csvdepth
+ \cptpushfunctions\indristloop{%
+ \\\user@do\\\indrisnr\\\iflastindris\\\ifloopbreak
+ }\cpt@csvdepth
\cpt@stchoose{cpt@st}{#1}\cpt@rsvda\indristloop
\advance\indrisdepth\@ne
\lastindrisfalse\loopbreakfalse
@@ -2010,7 +2014,7 @@
}%
}%
\expandafter\cpt@indristl@op\expandafter.\cpt@rsvda\cpt@nil\indris@nil
- \popfunctions\indristloop\cpt@csvdepth
+ \cptpopfunctions\indristloop\cpt@csvdepth
\advance\indrisdepth\m@one
}
%% Robust, multi-level, general-purpose tsv processor:
@@ -2027,16 +2031,18 @@
\cpt@stchoose{cpt@st}{#1}\cpt@tsvarg\cpt@tsvparse@a
% Use \cpt@csvdepth here also, to avoid premature undefining
% of pushed counterparts of \ifcpt@useempty, \ifloopbreak and
- % \cptdoremainder by \popfunctions:
- \pushfunctions\tsv@@parse{\sav@tsv@do,\ifcpt@useempty,
- \ifloopbreak,\cptdoremainder,\tsv@inparse}\cpt@csvdepth
+ % \cptdoremainder by \cptpopfunctions:
+ \cptpushfunctions\tsv@@parse{%
+ \\\sav@tsv@do\\\ifcpt@useempty\\\ifloopbreak\\\cptdoremainder
+ \\\tsv@inparse
+ }\cpt@csvdepth
\ifdefTF\tsv@do{}{%
\cpt@err{'\string\tsv@do' is undefined}\@ehc
}%
\let\sav@tsv@do\tsv@do
\loopbreakfalse
\expandafter\cpt@tsvparse@b\cpt@tsvarg\cpt@tsvnil
- \popfunctions\tsv@@parse\cpt@csvdepth
+ \cptpopfunctions\tsv@@parse\cpt@csvdepth
\ifnum\cpt@csvdepth=\z@pt
\undefcs\tsv@do
\fi
@@ -2085,12 +2091,12 @@
\cpt@stchoose{cpt@st}{#1}\siso@arg\siso@@loop
% Use \cpt@csvdepth here also, to avoid premature un-defining
% of pushed counterparts of \ifloopbreak:
- \pushfunctions\siso@@loop{\sav@siso@do,\ifloopbreak}\cpt@csvdepth
+ \cptpushfunctions\siso@@loop{\\\sav@siso@do\\\ifloopbreak}\cpt@csvdepth
\ifdefTF\siso@do{}{\cpt@notdeferr\siso@do}%
\let\sav@siso@do\siso@do
\loopbreakfalse
\expandafter\cpt@sisoloop@a\siso@arg\cpt@sisonil
- \popfunctions\siso@@loop\cpt@csvdepth
+ \cptpopfunctions\siso@@loop\cpt@csvdepth
\ifnum\cpt@csvdepth=\z@pt\undefcs\siso@do\fi
}
\robust@def*\cpt@sisoloop@a#1{%
@@ -2108,13 +2114,20 @@
\def\siso@do##1{#2}%
\cptexpanded{\siso@@loop\ifcpt@st*\fi}{#1}%
}
-% Any type of argument and delimiter is allowed in \cptforeach.
-% Eg,
+%
+% 1. Any type of parser, argument and delimiter are allowed in \cptforeach.
+% 2. It is permissible to use #1, #2, #3, etc, to refer to the elements of
+% list in the callback.
+% 3. Control sequences can't be used as delimiters in #2.
+% 4. Star (*) suffix implies that <list> is a command.
+% 6. This can't be used to fill/complete the list before processing.
+% See keyreader-for package for that feature.
+%
+% Example:
+%
% \newcount\nr
% \cptforeach[;] \xa/\ya/\za \in a1/b1/c1; a2/b2/c2; a3/b3/c3 \do{%
% \nr\z@pt
-% It is permissible to use #1, #2, #3 to refer to the elements
-% of each list, but they won't be despaced as \x, \y, \z will be:
% \cptforeach[,] \xs|\ys|\zs \in s1|t1|u1, s2|t2|u2, s3|t3|u3 \do{%
% \advance\nr\@ne
% \ifnum\nr>\@ne\loopbreak\fi
@@ -2122,55 +2135,70 @@
% \edef\cmdb####1{\xa\ya\za*####1*\xs\ys\zs}%
% }%
% }
-% Control sequences can't be used as delimiters in #2.
-% Star (*) suffix implies that <list> is a command.
+%
+\cptnewcounts[cpt@]{foreachdepth}
\robust@def*\cptforeach{\cpt@teststopt\cpt@foreach,}
\robust@def*\cpt@foreach[#1]#2\in#3\do#4{%
- \let\ifforeach@st\ifcpt@st
- \def\cpt@tempa{}%
- \cpttfor#2\dofor{%
- \ifescapedTF{##1}{\cptuaddtolist\cpt@tempa{##1}}{}%
- }%
- \cptexpandargonce{\pushfunctions\cptforeach}\cpt@tempa\cpt@csvdepth
\begingroup
- % We need a special scanner here:
- \def\rescan##1{%
- \begingroup
- \endlinechar\m@one\newlinechar\m@one
- \everyeof{\@@nnil}%
- \def\reserved@a####1\@@nnil{\endgroup\edef##1{\unexpanded{####1}}}%
- \expandafter\reserved@a\scantokens\expandafter{##1}%
- }%
- \@tempcnta\z@pt
- \def\cmds{}\def\params{}%
+ \let\if@foreach@st\ifcpt@st
+ \global\advance\cpt@foreachdepth\@ne
+ \@tempcnta\z@pt\def\cpt@tempc{}%
+ \def\cpt@cmds{}\def\cpt@params{}%
\cpttfor#2\dofor{%
\ifescapedTF{##1}{%
\advance\@tempcnta\@ne
- \edef\cmds{\expandcsonce\cmds\edef\unexpanded{##1}%
- {\noexpand\cpttrimspace{\cpt@hashchar\number\@tempcnta}}}%
- \edef\params{\expandcsonce\params\cpt@hashchar\number\@tempcnta}%
+ \edef\cpt@cmds{%
+ \expandcsonce\cpt@cmds
+ \edef\unexpanded{##1}{%
+ \noexpand\unexpanded{########\number\@tempcnta}%
+ }%
+ }%
+ \edef\cpt@params{\expandcsonce\cpt@params########\number\@tempcnta}%
+ \edef\cpt@tempc{\expandcsonce\cpt@tempc\unexpanded{\\##1}}%
}{%
\ifnum\@tempcnta=\z@pt
\cpt@err{First item of \noexpand\cptforeach can't
\MsgBrk be a delimiter}\@ehc
+ \else
+ \ifnum\@tempcnta=\@ne
+ \edef\cpt@subparser{\cpttrimspace{##1}}%
+ \fi
+ \edef\cpt@params{\expandcsonce\cpt@params\unexpanded{##1}}%
\fi
- \edef\params{\expandcsonce\params\unexpanded{##1}}%
}%
}%
- \rescan\cmds\rescan\params
+ \edef\cpt@tempb{\unexpanded{#3}}%
+ \expandafter\cpt@sttrue\expandafter\cpt@csvnormalize
+ \expandafter[\cpt@subparser]\cpt@tempb
+ % Add one extra parameter:
+ \edef\cpt@params{%
+ \expandcsonce\cpt@params
+ \cpt@subparser####\the\numexpr\@tempcnta+1\relax
+ }%
+ % Generate extra subparser list for padding:
+ \@tempcnta\z@pt\def\cpt@tempa{}%
+ \cptloop
+ \edef\cpt@tempa{\cpt@tempa\cpt@subparser}%
+ \advance\@tempcnta\@ne
+ \ifnum\@tempcnta<8\relax
+ \cptrepeat
+ \edef\elt{\noexpandcsn{cpt@foreach@do@\romannumeral\cpt@foreachdepth}}%
+ \let\cpt@foreach@nil\relax
\cptexpanded{%
\endgroup
- \def\noexpandcsn{foreach@do@\romannumeral\cpt@csvdepth}%
- \expandcsonce\params\noexpand\foreach@nil
- {\expandcsonce\cmds\unexpanded{#4}}%
- \def\noexpand\csv@do####1{\noexpandcsn
- {foreach@do@\romannumeral\cpt@csvdepth}####1\noexpand\foreach@nil}%
- \csv@@parse\ifforeach@st*\fi
+ \cptpushfunctions\cptforeach{\expandcsonce\cpt@tempc}\cpt@csvdepth
+ \def\expandcsonce\elt\expandcsonce\cpt@params\cpt@foreach@nil{%
+ \expandcsonce\cpt@cmds\unexpanded{#4}%
+ }%
+ \def\noexpand\csv@do####1{%
+ \expandcsonce\elt####1\cpt@tempa\cpt@foreach@nil
+ }%
+ \csv@@parse\if@foreach@st*\fi[#1]{\expandcsonce\cpt@tempb}%
}%
- [#1]{#3}%
- \popfunctions\cptforeach\cpt@csvdepth
- \undefcs\ifforeach@st
+ \cptpopfunctions\cptforeach\cpt@csvdepth
+ \global\advance\cpt@foreachdepth\m@ne
}
+
\robust@def*\cpt@oncurrlevel#1#2{%
\ifdefTF\curr@level{%
\ifnum\curr@level=\z@pt
@@ -2187,7 +2215,7 @@
% #2: token list
\new@def*\csliststack#1#2{%
\iflacus#2\dolacus\else
- \expandafter\ifnullTF\expandafter{\iiofii#2{}}{%
+ \expandafter\ifnullTF\expandafter{\cptiiofii#2{}}{%
\ifdefTF{#2}{%
\ifx#2\@empty\else\expandcsonce{#2}#1\fi
}{}%
@@ -2224,7 +2252,7 @@
}
\robust@def*\cpt@emptifycsset#1{%
\cptfor#1\dofor{%
- \ifsingletokenTF{##1}{%
+ \ifntypeTF{##1}{%
\ifescapedTF{##1}{%
\ifcpt@cl\global\fi\def##1{}%
}{%
@@ -2264,7 +2292,7 @@
\ifescapedFT{##1}{%
\cpt@notescapederr{##1}%
}{%
- \ifsingletokenTF{##1}{%
+ \ifntypeTF{##1}{%
\xifinsetTF{\detokenize{\do##1}}%
{\cptoxdetok\cpt@preamblecmdhook}{%
\cpt@warn{Command '\unexpanded{##1}' multiply
@@ -2342,7 +2370,7 @@
}%
}%
}
-\new@def*\ifcsnullFT#1{\ifcsnullTF{#1}\iiofii\iofii}
+\new@def*\ifcsnullFT#1{\ifcsnullTF{#1}\cptiiofii\cptiofii}
\new@def*\oifcsnullTF#1{\expandafter\ifcsnullTF\expandafter{#1}}
\new@def*\oifcsnullFT#1{\expandafter\ifcsnullFT\expandafter{#1}}
\new@def\ifcsemptyTF#1{%
@@ -2363,19 +2391,17 @@
}%
}%
}
-\new@def*\ifcsnnullFT#1{%
- \ifcsnnullTF{#1}\iiofii\iofii
-}
+\new@def*\ifcsnnullFT#1{\ifcsnnullTF{#1}\cptiiofii\cptiofii}
\new@def*\ifdefnotnullTF#1{%
\ifdefTF{#1}{%
- \ifcsnullTF{#1}\iiofii\iofii
+ \ifcsnullTF{#1}\cptiiofii\cptiofii
}{%
\@secondoftwo
}%
}
\new@def*\ifcsndefnotnullTF#1{%
\ifcsndefTF{#1}{%
- \ifcsnnullTF{#1}\iiofii\iofii
+ \ifcsnnullTF{#1}\cptiiofii\cptiofii
}{%
\@secondoftwo
}%
@@ -2475,18 +2501,18 @@
}%
}%
}
-\new@def*\ifdefboolFT#1{\ifboolTF{#1}\iiofii\iofii}
+\new@def*\ifdefboolFT#1{\ifdefboolTF{#1}\cptiiofii\cptiofii}
\new@def*\ifdefboolTF#1{%
\usename{@\usename{if#1}first\else second\fi oftwo}%
}
-\new@def*\ifboolFT#1{\ifdefboolTF{#1}\iiofii\iofii}
+\new@def*\ifboolFT#1{\ifboolTF{#1}\cptiiofii\cptiofii}
\new@def*\ifgroupboolTF#1{%
- \ifboolTF{#1}{\endgroup\iofii}{\endgroup\iiofii}%
+ \ifboolTF{#1}{\endgroup\cptiofii}{\endgroup\cptiiofii}%
}
\new@def*\ifbooleanTF#1#{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\ifescapedTF{#1}{%
- \ifboolTF{\cptremovescape#1}\iofii\iiofii
+ \ifboolTF{\cptremovescape#1}\cptiofii\cptiiofii
}{%
\cpt@notescapederr
}%
@@ -2574,14 +2600,14 @@
\ifstrcmpTF{##2##3}{#4#3}{%
\toks@{##1##4##3##2}%
}{%
- \ifsingletokenTF{##2}{%
- \ifsingletokenTF{##3}{%
+ \ifntypeTF{##2}{%
+ \ifntypeTF{##3}{%
\toks@{##1##2##3##4}%
}{%
\toks@{##1##2{##3}##4}%
}%
}{%
- \ifsingletokenTF{##3}{%
+ \ifntypeTF{##3}{%
\toks@{##1{##2}##3##4}%
}{%
\toks@{##1{##2}{##3}##4}%
@@ -2626,7 +2652,7 @@
\def\cpt@tempd{%
\ifstrcmpTF{##3}{#2}{%
\ifstrcmpTF{##2}{#3}{%
- \ifsingletokenTF{##4}{%
+ \ifntypeTF{##4}{%
\toks@{##1##3##2##4}%
}{%
\toks@{##1##3##2{##4}}%
@@ -2641,7 +2667,7 @@
\def\cpt@tempe{%
\ifstrcmpTF{##3}{#3}{%
\ifstrcmpTF{##2}{#2}{%
- \ifsingletokenTF{##4}{%
+ \ifntypeTF{##4}{%
\toks@{##1##2##3##4}%
}{%
\toks@{##1##2##3{##4}}%
@@ -2654,18 +2680,18 @@
}%
}%
\def\cpt@tempf{%
- \ifsingletokenTF{##4}{\toks1{##4}}{\toks1{{##4}}}%
+ \ifntypeTF{##4}{\toks1{##4}}{\toks1{{##4}}}%
\cpt@tempg
}%
\def\cpt@tempg{%
- \ifsingletokenTF{##3}{%
- \ifsingletokenTF{##2}{%
+ \ifntypeTF{##3}{%
+ \ifntypeTF{##2}{%
\cpt@temph{##1##2##3}%
}{%
\cpt@temph{##1{##2}##3}%
}%
}{%
- \ifsingletokenTF{##2}{%
+ \ifntypeTF{##2}{%
\cpt@temph{##1##2{##3}}%
}{%
\cpt@temph{##1{##2}{##3}}%
@@ -2677,13 +2703,13 @@
}%
\def\cpt@tempi{%
\ifstrcmpTF{##2}{#4}{%
- \ifsingletokenTF{##4}{%
+ \ifntypeTF{##4}{%
\toks@{##1##3##2##4}%
}{%
\toks@{##1##3##2{##4}}%
}%
}{%
- \ifsingletokenTF{##4}{%
+ \ifntypeTF{##4}{%
\toks@{##1##2##3##4}%
}{%
\toks@{##1##2##3{##4}}%
@@ -2707,7 +2733,7 @@
\robust@def*\cptglueexpr{\cpt@testcl{\cpt@numexpr{glue}}}
\robust@def*\cptmuexpr{\cpt@testcl{\cpt@numexpr{mu}}}
\new@def*\cpt@numexpr#1#2#3{%
- \ifsingletokenTF{#2}{}{\cpt@notonetokenerr{#2}}%
+ \ifntypeTF{#2}{}{\cpt@notonetokenerr{#2}}%
\ifescapedTF{#2}{}{\cpt@notescapederr{#2}}%
\ifdefTF{#2}{%
\ifcpt@cl\global\fi#2=\usename{#1expr}#3\relax\relax
@@ -2724,7 +2750,7 @@
\robust@def*\cptgluedef{\cpt@testcl{\cpt@numdef{glue}}}
\robust@def*\cptmudef{\cpt@testcl{\cpt@numdef{mu}}}
\new@def*\cpt@numdef#1#2#3{%
- \ifsingletokenTF{#2}{}{\cpt@notonetokenerr{#2}}%
+ \ifntypeTF{#2}{}{\cpt@notonetokenerr{#2}}%
\ifescapedTF{#2}{}{\cpt@notescapederr{#2}}%
\ifcpt@cl\global\fi\edef#2{\the\usename{#1expr}#3}%
}
@@ -2733,7 +2759,7 @@
\robust@def*\cptglueadd{\cpt@testcl{\cpt@numadd{glue}}}
\robust@def*\cptmuadd{\cpt@testcl{\cpt@numadd{mu}}}
\new@def*\cpt@numadd#1#2#3{%
- \ifsingletokenTF{#2}{}{\cpt@notonetokenerr{#2}}%
+ \ifntypeTF{#2}{}{\cpt@notonetokenerr{#2}}%
\ifescapedTF{#2}{}{\cpt@notescapederr{#2}}%
\ifdefTF{#2}{%
\ifcpt@cl\global\fi\edef#2{\the\usename{#1expr}#2+#3}%
@@ -2755,15 +2781,15 @@
\usename{@\ifnum\cpt@pdfstrcmp{#1}{#2}=0first\else
second\fi oftwo}%
}
-\new@def\xifstrcmpFT#1#2{\xifstrcmpTF{#1}{#2}\iiofii\iofii}
+\new@def\xifstrcmpFT#1#2{\xifstrcmpTF{#1}{#2}\cptiiofii\cptiofii}
\new@def\oifstrcmpTF#1#2{%
\expandafter\cptswapbracefirst\expandafter{#1}
{\expandafter\ifstrcmpTF\expandafter{#2}}%
}
\robust@def\oifstrcmp@sp@TF#1#2{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\ifexpandableTF{#1}{%
- \ifsingletokenTF{#2}{%
+ \ifntypeTF{#2}{%
\ifexpandableTF{#2}{%
\oifstrcmpTF{#1}{#2}%
}{%
@@ -2784,7 +2810,7 @@
}%
}
\robust@def\oifstrcmpFT#1#2{%
- \oifstrcmpTF{#1}{#2}\iiofii\iofii
+ \oifstrcmpTF{#1}{#2}\cptiiofii\cptiofii
}
% Expandable:
\new@def\ifstreqTF#1#2{%
@@ -2793,7 +2819,7 @@
{\expandafter\ifstrcmpTF\expandafter
{\romannumeral-`\q\cpttrimspaces{#2}}}%
}
-\robust@def\ifstreqFT#1#2{\ifstreqTF{#1}{#2}\iiofii\iofii}
+\robust@def\ifstreqFT#1#2{\ifstreqTF{#1}{#2}\cptiiofii\cptiofii}
\robust@def\oifstreqTF#1#2{\cptexpandtwoargsonce\ifstreqTF{#1}{#2}}
\robust@def\oifstreqFT#1#2{\cptexpandtwoargsonce\ifstreqFT{#1}{#2}}
\robust@def\xifstreqTF#1#2{\cptexpandtwoargs\ifstreqTF{#1}{#2}}
@@ -2814,12 +2840,12 @@
}\@secondoftwo
}\@secondoftwo
}
-\new@def\ifdefeqFT#1#2{\ifdefeqTF{#1}{#2}\iiofii\iofii}
+\new@def\ifdefeqFT#1#2{\ifdefeqTF{#1}{#2}\cptiiofii\cptiofii}
\new@def\ifcateqTF#1#{\usename{@\ifcat#1first\else second\fi oftwo}}
% Expand and detokenize before comparison:
\new@def\ifcharcmpTF#1#2{%
- \ifsingletokenTF{#1}{%
- \ifsingletokenTF{#2}{%
+ \ifntypeTF{#1}{%
+ \ifntypeTF{#2}{%
\usename{@\if\detokenize\expandafter{\romannumeral\expandafter
\cptswap\expandafter{\romannumeral-`\q#2}{-`\q#1}}%
first\else second\fi oftwo}%
@@ -2836,6 +2862,16 @@
\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}}%
{0 #2}{0 #3}%
}
+
+% Test if #1 is a single, non-space and non-braced token:
+\new@def\ifntypeTF#1{%
+ \if0\cpt@pdfstrcmp{\detokenize\expandafter{\cptalloftwo#1{}{}}}%
+ {\detokenize{#1{}}}%
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
\new@def\ifsingletokenTF#1#2#3{%
\romannumeral\ifblankTF{#1}\@secondoftwo{%
\ifbracedTF{#1}\@secondoftwo{%
@@ -2844,16 +2880,16 @@
}{%
\expandafter\ifblankTF\expandafter{\@gobble#1}%
}%
- \iofii\iiofii
+ \cptiofii\cptiiofii
}%
}{0 #2}{0 #3}%
}
-\new@def\ifsingletokenFT#1{\ifsingletokenTF{#1}\iiofii\iofii}
+\new@def\ifsingletokenFT#1{\ifntypeTF{#1}\cptiiofii\cptiofii}
% Don't test for \ifleadspaceTF:
\new@def\ifsingleindrisTF#1{%
\romannumeral
\ifblankTF{#1}{%
- 0 \iiofii
+ 0 \cptiiofii
}{%
% Eat one token and take the rest to \cpt@ifsingleindris:
\expandafter
@@ -2864,8 +2900,8 @@
\ifblankTF{#1}{%
\xifstrcmpTF{\expandafter\cpt@car
\detokenize{#2}x\car@nil}\cpt@leftbracechar
- {0 \iiofii}{0 \iofii}%
- }{0 \iiofii}%
+ {0 \cptiiofii}{0 \cptiofii}%
+ }{0 \cptiiofii}%
}
\robust@def*\ifsingledigitTF#1{%
\begingroup
@@ -2885,7 +2921,7 @@
\cpt@info{Parser '\detokenize{#1}' is a macro}\@ehc
\fi
}{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\xifinsetTF{\detokenize{#1}}\cpt@parserlist{%
#2% Don't put \relax here!
}{%
@@ -2945,7 +2981,7 @@
{cpt@afterassignment@\romannumeral\@tempcnta}%
}
\robust@def*\cptexpandmacro#1#2{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\ifmacroTF{#1}{%
\ifexpandableTF{#1}{%
\simpleexpandarg\cptexpandmacro{#1}#2%
@@ -2961,7 +2997,7 @@
}
% Expandable:
\new@def*\cptexpandcs#1{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\ifmacroTF{#1}{%
\ifexpandableTF{#1}{%
\simpleexpandarg\cptexpandcs{#1}%
@@ -3194,11 +3230,11 @@
\cpt@in{#1}{#2}%
\usename{@\ifcpt@in first\else second\fi oftwo}%
}
-\robust@def\ifinsetFT#1#2{\ifinsetTF{#1}{#2}\iiofii\iofii}
+\robust@def\ifinsetFT#1#2{\ifinsetTF{#1}{#2}\cptiiofii\cptiofii}
\robust@def\oifinsetTF#1#2{\cptexpandtwoargsonce\ifinsetTF{#1}{#2}}
-\robust@def\oifinsetFT#1#2{\oifinsetTF{#1}{#2}\iiofii\iofii}
+\robust@def\oifinsetFT#1#2{\oifinsetTF{#1}{#2}\cptiiofii\cptiofii}
\robust@def\xifinsetTF#1#2{\cptexpandtwoargs\ifinsetTF{#1}{#2}}
-\robust@def\xifinsetFT#1#2{\xifinsetTF{#1}{#2}\iiofii\iofii}
+\robust@def\xifinsetFT#1#2{\xifinsetTF{#1}{#2}\cptiiofii\cptiofii}
\robust@def\oifinset@sp@TF#1#2#3{%
\begingroup
\edef\parser{\detokenize{#1}}%
@@ -3207,10 +3243,10 @@
\expandafter\endgroup\expandafter\ifinsetTF\x
}
\robust@def\oifinset@sp@FT#1#2#3{%
- \oifinset@sp@TF{#1}{#2}{#3}\iiofii\iofii
+ \oifinset@sp@TF{#1}{#2}{#3}\cptiiofii\cptiofii
}
\robust@def*\cptifpattern#1\in#2{%
- \ifsingletokenTF{#2}{%
+ \ifntypeTF{#2}{%
\ifdefTF{#2}{%
\ifblankTF{#1}{%
\@secondoftwo
@@ -3596,7 +3632,7 @@
\robust@def*\cpt@undefcsset#1{%
\cpt@stchoose{cpt@st}{#1}\cpt@rsvda\undefcsset
\expandafter\cptfor\cpt@rsvda\dofor{%
- \ifsingletokenTF{##1}{%
+ \ifntypeTF{##1}{%
\ifescapedTF{##1}{%
\ifcpt@cl\global\fi\undefcs##1%
}{%
@@ -3648,7 +3684,7 @@
}
\robust@def*\cpttrimparsers{\cpt@testopt\cpt@trimparsers,}
\robust@def*\cpt@trimparsers[#1]#2{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\cpttrimleadparsers{#1}#2%
\cpttrimtrailparsers{#1}#2%
}{%
@@ -3750,7 +3786,7 @@
}%
}%
}
-\new@def*\ifmacroFT#1{\ifmacroTF{#1}\iiofii\iofii}
+\new@def*\ifmacroFT#1{\ifmacroTF{#1}\cptiiofii\cptiofii}
\new@def*\oifmacroTF#1{\simpleexpandarg\ifmacroTF{#1}}
\new@def*\ifcsnmacroTF{\aftercsname\ifmacroTF}
\edef\cpt@ifmacro{%
@@ -3766,7 +3802,7 @@
\aftercsname\endgroup
{@\ifx\x\@backslashchar first\else second\fi oftwo}%
}
-\robust@def*\ifescapedFT#1{\ifescapedTF{#1}\iiofii\iofii}
+\robust@def*\ifescapedFT#1{\ifescapedTF{#1}\cptiiofii\cptiofii}
% \robustaliascount counts the number of 'robustified' commands.
% It may be used to set a threshold for the no. of allowable
% aliases. \cptrobustify avoids \scantokens, because some commands
@@ -3776,7 +3812,7 @@
\def\csv@do##1{%
\ifescapedTF{##1}{%
\ifdefTF{##1}{%
- \pushnumber\robustaliascount
+ \cptpushnumber\robustaliascount
\ifnum\robustaliascount<\maxrobustalias\relax
\ifcsndefTF{robbase@\cptgobblescape##1}{%
\cpt@warn{Command '\string##1' is already robust:
@@ -3816,7 +3852,7 @@
\robust@def*\leftaddtocsn{\aftercsname\leftaddtocs}
\robust@def*\gleftaddtocsn{\aftercsname\gleftaddtocs}
\robust@def\cpt@addtocs#1#2{%
- \ifsingletokenTF{#1}{%
+ \ifntypeTF{#1}{%
\ifescapedTF{#1}{%
\ifdefTF#1{%
\cpt@getmacroprefix{#1}%
@@ -3991,7 +4027,7 @@
\cpt@notogerr{#1}\@gobbletwo
}%
}
-\new@def*\iftogFT#1{\iftogTF{#1}\iiofii\iofii}
+\new@def*\iftogFT#1{\iftogTF{#1}\cptiiofii\cptiofii}
\new@def*\cptswtrue{00}
\new@def*\cptswfalse{01}
\def\reserved@a#1{%
@@ -4026,11 +4062,11 @@
\expandafter{\romannumeral-`\q#1}}{true}{00}{01}%
}
-\robust@def*\newswitch#1{\cpt@testopt{\cpt@newswitch#1}{false}}
+\robust@def*\cptnewswitch#1{\cpt@testopt{\cpt@newswitch#1}{false}}
\robust@def*\cpt@newswitch#1[#2]{%
\ifinsetTF{,}{#1}{%
- \cpt@err{Command \noexpand\newswitch doesn't accept list}
- {Please submit only one switch to \string\newswitch.}%
+ \cpt@err{Command \noexpand\cptnewswitch doesn't accept list}
+ {Please submit only one switch to \string\cptnewswitch.}%
}{}%
\xifinsetTF{,#1,}{,if,x,switch,tog,togg,bool,test,}{%
\cpt@err{Invalid switch name '#1'}\@ehc
@@ -4080,14 +4116,14 @@
\cpt@err{Switch '#1' is not defined}\@ehc
\@gobbletwo
}{%
- \if\usename{#1}\expandafter\iofii\else\expandafter\iiofii\fi
+ \if\usename{#1}\expandafter\cptiofii\else\expandafter\cptiiofii\fi
}%
}
-\new@def*\ifdefswitchFT#1{\ifdefswitchTF{#1}\iiofii\iofii}
+\new@def*\ifdefswitchFT#1{\ifdefswitchTF{#1}\cptiiofii\cptiofii}
\new@def*\ifswitchTF#1{%
- \if\usename{#1}\expandafter\iofii\else\expandafter\iiofii\fi
+ \if\usename{#1}\expandafter\cptiofii\else\expandafter\cptiiofii\fi
}
-\new@def*\ifswitchFT#1{\ifswitchTF{#1}\iiofii\iofii}
+\new@def*\ifswitchFT#1{\ifswitchTF{#1}\cptiiofii\cptiofii}
\new@def*\thebool@normal#1{\ifboolTF{#1}{true}{false}}
\new@def*\thebool@reverse#1{\ifboolTF{#1}{false}{true}}
\cptnewcounts[cpt@]{exprcnt}
@@ -4224,7 +4260,7 @@
}%
\siso@@loop{#1}%
\expandafter\endgroup\ifcpt@choicefd
- \expandafter\iofii\else\expandafter\iiofii\fi
+ \expandafter\cptiofii\else\expandafter\cptiiofii\fi
}
% #1: listcmd
% #2: comparator: < (ascending) or > (descending)
@@ -4241,7 +4277,7 @@
\def\reserved@a##1#2##2##3\cpt@nil{%
\def\numcmp####1#2####2####{%
\usename{FPif##2}{####1}{####2}%
- \expandafter\iofii\else\expandafter\iiofii\fi
+ \expandafter\cptiofii\else\expandafter\cptiiofii\fi
}%
}%
\reserved@a={eq}>{gt}<{lt}\cpt@nil
@@ -4266,7 +4302,7 @@
\begingroup
\def\numcmp##1#2##2##{%
\ifnum\cpt@pdfstrcmp{##1}{##2}#2\z@pt
- \expandafter\iofii\else\expandafter\iiofii\fi
+ \expandafter\cptiofii\else\expandafter\cptiiofii\fi
}%
\cpt@sortlist{#1}{#2}%
}
@@ -4629,7 +4665,7 @@
\cpt@tempa
}%
}
-\robust@def*\ifinstylefileTF{\ifcsemptyTF\@currname\iiofii\iofii}
+\robust@def*\ifinstylefileTF{\ifcsemptyTF\@currname\cptiiofii\cptiofii}
\robust@def*\cpt@pushhash{%
\begingroup
\@makeother{\#}%
@@ -4725,9 +4761,8 @@
\def\reserved@a##1^?##2\nmlz@nil{\toks@{##1##2}}%
\expandafter\reserved@a\the\toks@\nmlz@nil
}%
- \def\reserved@a#1##1\nmlz@nil{\edef\normalized@list{\unexpanded{##1}}}%
- \expandafter\reserved@a\the\toks@\nmlz@nil
-% \cpttrimleadparsers#1\normalized@list
+ \edef\normalized@list{\the\toks@}%
+ \cpttrimleadparsers#1\normalized@list
\cptexpanded{\endgroup
\ifdefboolTF{@nmlzst}{%
\edef\noexpand#2{\ox@unexpanded\normalized@list}%
@@ -5686,12 +5721,12 @@
}
\robust@def*\ifindefaultdsTF{%
\begingroup
- \def\reserved@e{\iofii\iiofii}%
+ \def\reserved@e{\cptiofii\cptiiofii}%
\cpt@ifin@default@ds
}
\robust@def*\ifindefaultdsFT{%
\begingroup
- \def\reserved@e{\iiofii\iofii}%
+ \def\reserved@e{\cptiiofii\cptiofii}%
\cpt@ifin@default@ds
}
\robust@def*\cpt@ifin@default@ds#1{%
@@ -5995,10 +6030,10 @@
}%
}
\robust@def*\cpt@optionstate{%
- \cpt@currfams,\cpt@curroptvals,\cpt@currfam,\cpt@currna,%
- \cpt@curropt,\cpt@currval,\CurrentOption,\OptionFound,%
- \ifcpt@inpox,\ifcpt@optfd,\ifcpt@igopt,\DeclaredOptions,%
- \ExecutedOptions
+ \\\cpt@currfams\\\cpt@curroptvals\\\cpt@currfam\\\cpt@currna
+ \\\cpt@curropt\\\cpt@currval\\\CurrentOption\\\OptionFound
+ \\\ifcpt@inpox\\\ifcpt@optfd\\\ifcpt@igopt\\\DeclaredOptions
+ \\\ExecutedOptions
}
\robust@def*\cpt@removecurroption#1{%
\cptexpandargonce{\cptfilterremovekv[,]%
@@ -6133,7 +6168,7 @@
\cpt@relax
}
\robust@redef*\ExecuteOptions#1{%
- \pushfunctions\ExecuteOptions\CurrentOption\cpt@optdepth
+ \cptpushfunctions\ExecuteOptions{\\\CurrentOption}\cpt@optdepth
\edef\CurrentOption{\unexpanded{#1}}%
\cpt@sttrue\cpt@kvnormalize[,]\CurrentOption
\cpt@removevalues\CurrentOption
@@ -6142,11 +6177,11 @@
\csname ds@##1\endcsname
}%
\csv@@parse*\CurrentOption
- \popfunctions\ExecuteOptions\cpt@optdepth
+ \cptpopfunctions\ExecuteOptions\cpt@optdepth
}
\robust@redef\@pass@ptions#1#2#3{%
\begingroup
- \ifsingletokenTF{#2}{%
+ \ifntypeTF{#2}{%
\ifmacroTF{#2}{%
\let\@expand\expandcsonce
}{%
@@ -6181,7 +6216,7 @@
}
\let\@@fileswith@pti@ns\@fileswith@pti@ns
\robust@redef*\ProcessOptions{%
- \pushfunctions\ProcessOptions\CurrentOption\cpt@optdepth
+ \cptpushfunctions\ProcessOptions{\\\CurrentOption}\cpt@optdepth
\cpt@sttrue\cpt@csvnormalize[,]\@declaredoptions
\cpt@sttrue\cpt@kvnormalize[,]\@classoptionslist
\edef\@curroptions{\cpt@optionlist{\@currname.\@currext}}%
@@ -6227,7 +6262,7 @@
\expandafter\cptfor\@declaredoptions\dofor{%
\letcsntocs{ds@##1}\relax
}%
- \popfunctions\ProcessOptions\cpt@optdepth
+ \cptpopfunctions\ProcessOptions\cpt@optdepth
\let\@fileswith@pti@ns\@@fileswith@pti@ns
\AtEndOfPackage{\let\@unprocessedoptions\relax}%
}
@@ -6314,3 +6349,28 @@
\endinput
%% End of file catoptions.sty %%
+
+
+
+
+\robust@def*\cptpushfunctions#1#2#3{%
+ \cptpushnumber{#3}%
+ \begingroup
+ \edef\cpt@stack{\cptremovescape{#1}@stack}%
+ \ifcsndefTF\cpt@stack{}{\csn@def\cpt@stack{}}%
+ \toks@{}\toks1{}\escapechar92\relax
+ % Using \csv@@loop or \csv@@parse here will bomb out,
+ % because \cptpushfunctions is called within those loops:
+ \let\xp\expandcsonce
+ \cptfor#2\dofor{%
+ \ifescapedTF{##1}{}{\cpt@notescapederr{##1}}%
+ \edef\cpt@tempa{\noexpandcsn{\cptremovescape{##1}@\cptrm#3}}%
+ \cptpassexpanded{%
+ \toks@{\the\toks@\let\xp\cpt@tempa\noexpand##1}%
+ \toks1{\the\toks1\let\noexpand##1\xp\cpt@tempa
+ \undefcs\xp\cpt@tempa}%
+ }%
+ }%
+ \csn@xdef\cpt@stack{\the\toks1\cpt@nil{\expandcsnonce\cpt@stack}}%
+ \expandafter\endgroup\the\toks@
+}