diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/catoptions/catoptions.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/catoptions/catoptions.sty | 1597 |
1 files changed, 1020 insertions, 577 deletions
diff --git a/Master/texmf-dist/tex/latex/catoptions/catoptions.sty b/Master/texmf-dist/tex/latex/catoptions/catoptions.sty index 0ccb627de06..cbfc83ab3ca 100644 --- a/Master/texmf-dist/tex/latex/catoptions/catoptions.sty +++ b/Master/texmf-dist/tex/latex/catoptions/catoptions.sty @@ -1,15 +1,15 @@ %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% This is 'catoptions' package (Version 0.1, August 2010) % +% This is 'catoptions' package (Version 0.2, August 2010) % % % % The catoptions package changes LaTeX package loading internals % % so that all subsequently loaded packages can rely on having % % normal catcodes in effect. The package also contains some useful % -% macros unconnected with catcodes. In particular, it contains % +% facilities unconnected with catcodes. In particular, it contains % % options processing facilities that have the familiar and simple % % syntax of LaTeX's legacy options parsing mechanism, but with % % improved robustness in terms of option value default, preservation % % of braces in option values, and parsing of expandable package % -% and class option values. % +% and class option values. Also, it contains some API. % % % % The catcode facilities of the package are an extension of the % % 'pcatcode' package by Michael J. Downes and David M. Jones. % @@ -28,7 +28,7 @@ \chardef\%\catcode37\catcode37 14\relax\expandafter\iffalse\string\ \fi\let\e\endlinechar\chardef\E\e\e13\chardef\n\catcode\e\catcode\e5 % \chardef\s\catcode32 \catcode32 10 -\chardef\==\catcode61 \catcode61 12 +\chardef\=\catcode61 \catcode61 12 \chardef\l=\catcode123 \catcode123=1 \chardef\r=\catcode125 \catcode125=2 \chardef\[=\catcode91 \catcode91=12 @@ -87,10 +87,9 @@ \chardef\cpt@xiipt=12 \chardef\active=13 \chardef\cpt@xciipt=92 -\ifx\@xp\expandafter\else\@ifdefinable\@xp{\let\@xp\expandafter}\fi \NeedsTeXFormat{LaTeX2e}[1995/12/01] \ProvidesPackage{catoptions} - [2011/01/01 v0.1 Preserving catcodes & parsing options (AM)] + [2011/02/021 v0.2 Preserving catcodes and parsing options (AM)] \ifcase% \ifx\eTeXversion\cpt@undefined\z@\else \ifnum\eTeXversion<\tw@\z@\else\@ne\fi\fi @@ -168,12 +167,29 @@ }% \expandafter\endgroup\x } -\def\cpt@fletmacros{} -\newcommand*\declarefutureletprefix[1]{% - \gdef\cpt@fletprefix{#1}% - \gdef\cpt@fletmacros{}% +\newcommand*\declarefutureletset[2][fl@]{% + \xdef\cpt@fletprefix{\xp@despace{#1}}% + \cptexpandargonce + {\cpt@filtermergelists[,]\cpt@fletprefixes}\cpt@fletprefix{}% + \ifblankTF{#2}{% + \def\neededfutureletchars{}% + }{% + \def\neededfutureletchars{#2}% + \cpt@sttrue\cpt@csvnormalize[,]\neededfutureletchars + \oifstrcmpFT\neededfutureletchars{all}{}{% + \def\neededfutureletchars{}% + \def\cpt@tempa##1\@##2\@{% + \ifx##1\end\else + \cptaddtocommalist\neededfutureletchars{##1}% + \expandafter\cpt@tempa + \fi + }% + \expandafter\cpt@tempa\cpt@futureletchars\end\@\@ + }% + }% + \globalize\neededfutureletchars + \globalize\cpt@fletprefixes } -\declarefutureletprefix{fl@} \begingroup \cptrestorecatcodes \begingroup @@ -183,11 +199,16 @@ \begingroup \edef\cpt@tempa{\noexpandcsn{\cpt@fletprefix#1}}% \edef\cpt@tempb{\noexpandcsn{if\cpt@fletprefix#1}}% - \oifinsetTF\cpt@tempa\cpt@fletmacros{}{% - \edef\x{\g@right@addto@macro\noexpand\cpt@fletmacros - {\expandcsonce\cpt@tempa\expandcsonce\cpt@tempb}}% - \x + \xifinsetTF + {,\cptoxdetok\cpt@tempa,}{,\cptoxdetok\cptfutureletmacros,}{}{% + \xdef\cptfutureletmacros{% + \ifcsnullTF\cptfutureletmacros{}% + {\expandcsonce\cptfutureletmacros,}% + \expandcsonce\cpt@tempa,\expandcsonce\cpt@tempb + }% }% + \def\siso@do##1{\lccode`##1=`#2}% + \simplesisoloop{034678BCD}% \lccode`\0=`#2\lccode`\3=`#2\lccode`\4=`#2\lccode`\6=`#2% \lccode`\7=`#2\lccode`\8=`#2\lccode`\B=`#2\lccode`\C=`#2% \lccode`\D=`#2% @@ -224,45 +245,44 @@ } \gdef\cptfutureletsetup{% \gdef\cpt@activecharacters{}% + \gdef\cptfutureletmacros{}% \def\cpt@flet@b##1\@##2\@{% \ifx##1\end\else - \cpt@flet@a{##1}{##2}% + \xifinsetFT{##1}\neededfutureletchars{}{% + \cpt@flet@a{##1}{##2}% + }% \expandafter\cpt@flet@b \fi }% + \def\fifo@do##1{% + \gundefcsn{##1\currentoption}% + \gundefcsn{if##1\currentoption}% + }% \def\cpt@fletundef##1\@##2\@{% \ifx##1\end\else - \begingroup - \edef\x{\noexpandcsn{\cpt@fletprefix##1}}% - \expandafter\ifdefTF\x{% - \oifinsetTF\x\cpt@fletmacros{}{% - \cpt@err{Invalid futurelet prefix '\expandcsonce - \cpt@fletprefix'.\MsgBrk You can use - \string\declarefutureletprefix\space to select - \MsgBrk another prefix}\@ehc - }% - }{}% - \endgroup - \undef@csn{\cpt@fletprefix##1}% - \undef@csn{if\cpt@fletprefix##1}% + \def\currentoption{##1}% + \simpleexpandarg\simplefifoloop{\cpt@fletprefixes}% \expandafter\cpt@fletundef \fi }% \def\cpt@fletdef##1\@##2\@{% - \ifx##1\end\else - \csn@xdef{if\cpt@fletprefix##1}####1{% - \noexpand\@nameuse{@\noexpand\ifx - \noexpandcsn{\cpt@fletprefix##1}% - ####1\unexpanded{\@empty first\else second\fi oftwo}}% + \ifxTF##1\end{}{% + \xifinsetFT{##1}\neededfutureletchars{}{% + \csn@xdef{if\cpt@fletprefix##1}####1{% + \noexpand\usecsn{@\noexpand\ifx + \noexpandcsn{\cpt@fletprefix##1}% + ####1\unexpanded{\@empty first\else second\fi oftwo}% + }% + }% }% - \expandafter\cpt@fletdef - \fi + \cpt@fletdef + }% }% \expandafter\cpt@fletundef\cpt@futureletchars\end\@\@ \expandafter\cpt@fletdef\cpt@futureletchars\end\@\@ \expandafter\cpt@flet@b\cpt@futureletchars\end\@\@ } -\AtBeginDocument{\cptrestorecatcodes\cptfutureletsetup} +\AtBeginDocument{\cptrestorecatcodes} \gdef\futureletresetactives{% \def\do##1##2{\let##1= ##2}% \cpt@activecharacters @@ -272,32 +292,38 @@ \@ifdefinable\UseNormalCatcodes\relax \protected\def\UseNormalCatcodes{% - \ifcsemptyF\@currname{% + \ifcsnullTF\@currname{% + \cpt@warn{\noexpand\UseNormalCatcodes issued in + document: ignored}% + }{% \let\UseNormalCatcodes\relax \cptpushcatcodes \cptnormalcatcodes - \cptfutureletsetup \AfterEndOfStyleFile{% \cptpopcatcodes \let\UseNormalCatcodes\rc@UseNormalCatcodes }% }% } -\@ifdefinable\rc@UseNormalCatcodes\relax -\global\let\rc@UseNormalCatcodes\UseNormalCatcodes +\@ifdefinable\rc@UseNormalCatcodes{% + \global\let\rc@UseNormalCatcodes\UseNormalCatcodes +} \newcommand\cptswap[2]{#2#1} \newcommand\cptswapfirstbraced[2]{#2{#1}} \cptswap{ }{\let\@sptoken= } \def\@space{ } -\long\def\@nameuse#1{\csname#1\endcsname} +\newcommand\usecsn[1]{\csname#1\endcsname}% long +\newcommand\gusecsn[1]{\global\csname#1\endcsname} +\newcommand\cptuse[1]{\ifcsndefFT{#1}{}{\usecsn{#1}}} \long\def\@gobblethree#1#2#3{} \long\def\@firstofthree#1#2#3{#1} \long\def\@secondofthree#1#2#3{#2} \long\def\@thirdofthree#1#2#3{#3} \let\@iden\@firstofone -\newcommand\@alloftwo[2]{#1#2} +\newcommand\cptalloftwo[2]{#1#2} \protected\def\cpt@nil{} \def\cpt@nnil{\cpt@nil} +\protected\def\cpt@unique{\cpt@unique} \long\def\cpt@car#1#2\car@nil{#1} \long\def\cpt@cdr#1#2\cdr@nil{#2} \long\def\remove@to@nnil#1\@nnil{} @@ -305,64 +331,78 @@ \long\def\remove@to@dot#1.{} \long\def\catch@to@dot#1.{#1} \@ifdefinable\cpt@rnm{\let\cpt@rnm\romannumeral} -\def\cpt@rmnstop{0 } \def\cptthreexp{\expandafter\expandafter\expandafter} \def\cptsevenxp{\expandafter\expandafter\expandafter \expandafter\expandafter\expandafter\expandafter} \protected\def\cptlocalxp#1{\begingroup\cptthreexp\endgroup#1} \protected\def\cptlocalxpxp{\cptlocalxp\expandafter} \newcommand*\cptzapspaces[1]{% - \def\cptzapspaces##1{% - \cpt@rnm0\cpt@zapspaces.\@space##1#1\cpt@nil - }% + \def\cptzapspaces##1{\cpt@rnm0\cpt@zapspaces.\@space##1#1\cpt@nil}% } \cptzapspaces{ } \def\cpt@zapspaces#1 #2\cpt@nil{% - \@nameuse{@\ifx\\#2\\first\else second\fi oftwo}% + \usecsn{@\ifx\cpt@unique#2\cpt@unique first\else second\fi oftwo}% {\remove@to@dot#1}{% \expandafter\cpt@zapspaces\expandafter .\remove@to@dot#1#2\cpt@nil }% } +\newcommand*\ifpdfstrcmpTF[2]{% + \usecsn{@\ifnum\pdfstrcmp{\detokenize{#1}}% + {\detokenize{#2}}=\z@ first\else second\fi oftwo}% +} \@ifdefinable\kernel@for{\let\kernel@for\@for} -\@ifdefinable\newvariables\relax -\protected\def\newvariables#1#2#3{% - \@testopt{\cpt@newvariables{#1}{#2}{#3}}{}% +\newcommand*\newvariables[1]{\@testopt{\cpt@newvariables{#1}}{}}% +\protected\def\cpt@newvariables#1[#2]#3{% + \@testopt{\cpt@newv@riables{#1}{#2}{#3}}{}% } -\protected\def\cpt@newvariables#1#2#3[#4]{% - \edef\cpt@tempb{\ifnum\pdfstrcmp{#1}{if}=\z@ if\fi}% +\protected\def\cpt@newv@riables#1#2#3[#4]{% + \def\cpt@rsvda##1{% + \ifx\cpt@unique#4\cpt@unique\def\cpt@tempc{##1}\else + \def\cpt@tempc{#4}\fi + }% + \edef\cpt@tempb{\ifpdfstrcmpTF{#1}{if}{if}{}}% \kernel@for\cpt@tempa:=\cpt@rnm0\cptzapspaces{\@space#3}\do{% - \@nameuse{@\ifcsname\cpt@tempb#2\cpt@tempa\endcsname + \usecsn{@\ifcsname\cpt@tempb#2\cpt@tempa\endcsname first\else second\fi oftwo}% {% \edef\reserved@a{\cpt@tempb#2\cpt@tempa}\@notdefinable }{% \csname new#1\expandafter\endcsname\csname \cpt@tempb#2\cpt@tempa\endcsname - \ifnum\pdfstrcmp{#1}{if}=\z@ - \ifx\\#4\\\def\cpt@tempc{false}\else\def\cpt@tempc{#4}\fi + \ifpdfstrcmpTF{#1}{if}{% + \cpt@rsvda{false}% \csname#2\cpt@tempa\cpt@tempc\endcsname - \else - \ifx\\#4\\\let\cpt@tempc\z@\else\def\cpt@tempc{#4}\fi - \csname#2\cpt@tempa\endcsname\cpt@tempc\relax - \fi + }{% + \ifpdfstrcmpTF{#1}{toks}{% + \cpt@rsvda{}% + \csname#2\cpt@tempa\endcsname\expandafter{\cpt@tempc}% + }{% + \ifpdfstrcmpTF{#1}{box}{% + \cpt@rsvda\z@ + \setbox\csname#2\cpt@tempa\endcsname\newboxtype + to\cpt@tempc{\newboxcontent}\relax + }{% + \cpt@rsvda\z@ + \csname#2\cpt@tempa\endcsname\cpt@tempc\relax + }% + }% + }% }% }% } -\newvariables{if}{cpt@}{st,pl,pm,verbose,usepox,optf,igopt, +\@ifdefinable\newboxtype{\let\newboxtype=\hbox} +\@ifdefinable\newboxcontent{\def\newboxcontent{}} +\newvariables{if}[cpt@]{st,pl,pm,verbose,usepox,optf,igopt, inpox,olddx}\relax -\newvariables{if}{@}{iscounter,breakloop,choicefd,useempty, - checklistparser,userobustdespace}\relax -\newvariables{count}{cpt@}{depth,grouplevel,grouptype}\relax +\newvariables{if}[@]{iscounter,breakloop,choicefd,useempty, + checklp,robdes}\relax +\newvariables{count}[cpt@]{depth,grouplevel,grouptype}\relax \@ifdefinable\cptbreakloop{\let\cptbreakloop\@breaklooptrue} -\@ifdefinable\UseEmptyEntry{% - \protected\def\UseEmptyEntry{\global\@useemptytrue}} -\@ifdefinable\DiscardEmptyEntry{% - \protected\def\DiscardEmptyEntry{\global\@useemptyfalse}} -\@ifdefinable\UseRobustDespace{% - \protected\def\UseRobustDespace{\global\@userobustdespacetrue}} -\@ifdefinable\UseNormalDespace{% - \protected\def\UseNormalDespace{\global\@userobustdespacefalse}} +\newcommand*\UseEmptyEntry{\global\@useemptytrue} +\newcommand*\DiscardEmptyEntry{\global\@useemptyfalse} +\newcommand*\UseRobustDespace{\global\@robdestrue} +\newcommand*\UseNormalDespace{\global\@robdesfalse} \newcommand*\MsgBrk{\MessageBreak} \newcommand*\cptgetcatcode[1]{% \number @@ -379,75 +419,77 @@ \ifcat\noexpand#1\noexpand~13\else -1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi } -\newcommand\cptremovescape[1]{\expandafter\@gobble\string#1} +\newcommand\cptremovescape[1]{% + \ifx\cpt@unique#1\cpt@unique + \expandafter\@gobble\else\expandafter\@iden\fi + {\expandafter\@gobble\string#1}% +} \newcommand\cptgobblescape[1]{% - \ifnum\escapechar>\@cclv\else + \ifx\cpt@unique#1\cpt@unique + \expandafter\@gobble\else\expandafter\@iden\fi + {\ifnum\escapechar>\@cclv\else \ifnum\escapechar<\z@\else \expandafter\expandafter \csname @gobble\ifnum\escapechar=\@xxxii @space\fi \cptthreexp\endcsname \fi\fi - \string#1% + \string#1}% } \newcommand\ifnullTF[1]{% - \@nameuse{@\ifnum\pdfstrcmp{}{\detokenize{#1}}% + \usecsn{@\ifnum\pdfstrcmp{}{\detokenize{#1}}% =\z@ first\else second\fi oftwo}% } \newcommand\ifnullFT[1]{\ifnullTF{#1}\@secondoftwo\@firstoftwo} -\newcommand\ifnullT[1]{\ifnullTF{#1}\@firstofone\@gobble} -\newcommand\ifnullF[1]{\ifnullTF{#1}\@gobble\@firstofone} -\@ifdefinable\ifstremptyTF{\let\ifstremptyTF\ifnullTF} -\@ifdefinable\ifstremptyFT{\let\ifstremptyFT\ifnullFT} -\@ifdefinable\ifstremptyT{\let\ifstremptyT\ifnullT} -\@ifdefinable\ifstremptyF{\let\ifstremptyF\ifnullF} +\newcommand\oifnullTF[1]{\expandafter\ifnullTF\expandafter{#1}} +\newcommand\oifnullFT[1]{\expandafter\ifnullFT\expandafter{#1}} +\newcommand\xifnullTF[1]{\cptexpandarg\ifnullTF{#1}} +\newcommand\xifnullFT[1]{\cptexpandarg\ifnullFT{#1}} \@ifdefinable\iftoksnullTF\relax \def\iftoksnullTF#1#{% \expandafter\ifnullTF\expandafter{\the#1}% } \newcommand\ifblankTF[1]{% - \@nameuse{@\ifnum\pdfstrcmp{}{\detokenize\expandafter + \usecsn{@\ifnum\pdfstrcmp{}{\detokenize\expandafter {\@gobble#1.}}=\z@ first\else second\fi oftwo}% } \newcommand\ifblankFT[1]{\ifblankTF{#1}\@secondoftwo\@firstoftwo} -\newcommand\ifblankT[1]{\ifblankTF{#1}\@firstofone\@gobble} -\newcommand\ifblankF[1]{\ifblankTF{#1}\@gobble\@firstofone} \newcommand\oifblankTF[1]{\expandafter\ifblankTF\expandafter{#1}} -\newcommand\xifblankTF[1]{\cptfullexpandarg\ifblankTF{#1}} +\newcommand\oifblankFT[1]{\expandafter\ifblankFT\expandafter{#1}} +\newcommand\xifblankTF[1]{\cptexpandarg\ifblankTF{#1}} +\newcommand\xifblankFT[1]{\cptexpandarg\ifblankFT{#1}} \newcommand*\ifdefTF[1]{% - \@nameuse{@\ifdefined#1\ifx#1\relax second\else first\fi + \usecsn{@\ifdefined#1\ifx#1\relax second\else first\fi \else second\fi oftwo}% } \newcommand*\ifdefFT[1]{\ifdefTF{#1}\@secondoftwo\@firstoftwo} -\newcommand*\ifdefT[1]{\ifdefTF{#1}\@firstofone\@gobble} -\newcommand*\ifdefF[1]{\ifdefTF{#1}\@gobble\@firstofone} +\newcommand*\oifdefTF[1]{\expandafter\ifdefTF\expandafter{#1}} +\newcommand*\oifdefFT[1]{\expandafter\ifdefFT\expandafter{#1}} +\newcommand*\xifdefTF[1]{\cptexpandarg\ifdefTF{#1}} +\newcommand*\xifdefFT[1]{\cptexpandarg\ifdefFT{#1}} \newcommand*\ifcsndefTF[1]{% \ifcsname#1\endcsname \expandafter\@firstofone \else \cptthreexp\@secondoftwo\expandafter\@gobble \fi - {\cptaftercs\ifdefTF{#1}}% + {\aftercsname\ifdefTF{#1}}% } \newcommand*\ifcsndefFT[1]{\ifcsndefTF{#1}\@secondoftwo\@firstoftwo} -\newcommand*\ifcsndefT[1]{\ifcsndefTF{#1}\@firstofone\@gobble} -\newcommand*\ifcsndefF[1]{\ifcsndefTF{#1}\@gobble\@firstofone} -\newcommand*\letnewcmd[2]{\ifcptdefinable{#1}{\let#1=#2}} +\newcommand*\oifcsndefTF[1]{\expandafter\ifcsndefTF\expandafter{#1}} +\newcommand*\oifcsndefFT[1]{\expandafter\ifcsndefFT\expandafter{#1}} +\newcommand*\xifcsndefTF[1]{\cptexpandarg\ifcsndefTF{#1}} +\newcommand*\xifcsndefFT[1]{\cptexpandarg\ifcsndefFT{#1}} +\newcommand*\newletcs[2]{\ifcptdefinable{#1}{\let#1=#2}} \newcommand*\ifcptdefinable[2]{% \edef\reserved@a{\cptgobblescape#1}% - \ifdefTF{#1}{% - \@notdefinable - }{% - \ifcsndefTF{end\reserved@a}{% - \@notdefinable - }{% - #2% - }% + \ifdefTF{#1}\@notdefinable{% + \ifcsndefTF{end\reserved@a}\@notdefinable{#2}% }% } \newcommand\cpt@def@[3]{% \ifcptdefinable#3{% - \ifstremptyTF{#2}{}\protected - \cptthreexp\l@ngrel@x\@nameuse{#1def}#3% + \ifnullTF{#2}{}\protected + \cptthreexp\l@ngrel@x\usecsn{#1def}#3% }% } \ifcptdefinable\robust@def\relax @@ -462,7 +504,7 @@ \robust@def*\renew@def{\@star@or@long{\cpt@redef@{}}} \robust@def*\robust@redef{\@star@or@long{\cpt@redef@{p}}} \new@def*\cpt@redef@#1#2{% - \ifdefT#2{% + \ifdefFT#2{}{% \ifcpt@verbose \@latex@info{Command '\string#2' redefined}% \fi @@ -471,12 +513,12 @@ } \new@def*\ifcounterTF#1{% \ifstrcmpTF{\count}{#1}\@secondoftwo{% - \expandafter\cpt@ifcounter@a\meaning#1:&% + \expandafter\cpt@ifcounter@a\meaning#1:\cpt@unique }% } \edef\cpt@ifcounter@a#1#2{% - \def#1##1:##2&{#2##1\string\count&}% - \def#2##1\string\count##2&{\noexpand\ifblankTF{##1}}% + \def#1##1:##2\cpt@unique{#2##1\string\count\cpt@unique}% + \def#2##1\string\count##2\cpt@unique{\noexpand\ifblankTF{##1}}% } \cpt@ifcounter@a\cpt@ifcounter@a\cpt@ifcounter@b \robust@def*\pushnumber#1{% @@ -511,7 +553,7 @@ }% \fi }{% - \@nameuse{newcount}#1% + \usecsn{newcount}#1% }% \@iscounterfalse } @@ -535,14 +577,14 @@ }% \@iscounterfalse } -\new@def*\push@rnarg#1{\@xp\cptremovescape\push@arg @\cpt@rnm#1} +\new@def*\push@rnarg#1{\expandafter\cptremovescape\push@arg @\cpt@rnm#1} \robust@def*\pushfunctions#1#2{% \ifcounterTF#2{% \@iscountertrue\pushcounter#2% }{% \global\pushnumber#2% }% - \def\push@@do{\csn@let@cs{\push@rnarg{#2}}}% + \def\push@@do{\letcsntocs{\push@rnarg{#2}}}% \def\push@do{\expandafter\push@@do\push@arg}% \let\rc@escapechar\escapechar\escapechar\cpt@xciipt \pushingloop{#1}% @@ -553,8 +595,8 @@ \cpt@err{Number '\string#2' is currently '0'}\@ehc \fi \def\push@do{% - \expandafter\cs@let@csn\push@arg{\push@rnarg{#2}}% - \undef@csn{\push@rnarg{#2}}% + \expandafter\letcstocsn\push@arg{\push@rnarg{#2}}% + \undefcsn{\push@rnarg{#2}}% }% \let\rc@escapechar\escapechar\escapechar\cpt@xciipt \pushingloop{#1}% @@ -565,12 +607,12 @@ \global\popnumber#2% }% } -\robust@def*\pushingloop#1{\cpt@pushingloop#1,\cpt@nil,&} -\robust@def*\cpt@pushingloop#1,#2&{% +\robust@def*\pushingloop#1{\cpt@pushingloop#1,\cpt@nil,} +\robust@def*\cpt@pushingloop#1,{% \edef\push@arg{\unexpanded{#1}}% - \ifxF\push@arg\cpt@nnil{% + \ifxTF\push@arg\cpt@nnil{}{% \normal@despacecontent\push@arg - \push@do\relax\cpt@pushingloop#2&% + \push@do\relax\cpt@pushingloop }% } \robust@def*\cpt@toodeep#1#2{% @@ -580,92 +622,85 @@ \@gobble } \robust@def*\oneDloop{% - \let\Dlooptype\@ne\cpt@ifstar\oneDloop@b\oneDloop@a + \@robdestrue\cpt@ifstar\oneDloop@b\oneDloop@a } \robust@def*\normaloneDloop{% - \let\Dlooptype\z@\cpt@ifstar\oneDloop@b\oneDloop@a + \@robdesfalse\cpt@ifstar\oneDloop@b\oneDloop@a } -\robust@def*\getDlooptype{% - \ifx\Dlooptype\cpt@undefined\let\Dlooptype\@ne\fi -} -\robust@def*\oneDloop@b#1{% - \getDlooptype - \expandafter\oneDloop@a\expandafter{#1}% -} -\robust@def*\oneDloop@a#1#2#3{% - \getDlooptype +\robust@def\oneDloop@b#1{\expandafter\oneDloop@a\expandafter{#1}} +\robust@def\oneDloop@a#1#2#3{% \pushnumber\oneDloopdepth \ifnum\oneDloopdepth>\@ne\cpt@toodeep\oneDloop1\fi \@breakloopfalse - \cpt@Dloop@a#1,\cpt@nil,{#3}% + \cpt@Dloop@a#1,\cpt@nil,\cpt@unique#2{#3}% \popnumber\oneDloopdepth + \UseNormalDespace } \robust@def*\xDloop{% - \let\Dlooptype\@ne\cpt@ifstar\xDloop@b\xDloop@a + \@robdestrue\cpt@ifstar\xDloop@b\xDloop@a } \robust@def*\normalxDloop{% - \let\Dlooptype\z@\cpt@ifstar\xDloop@b\xDloop@a -} -\robust@def*\xDloop@b#1{% - \getDlooptype - \expandafter\xDloop@a\expandafter{#1}% + \@robdesfalse\cpt@ifstar\xDloop@b\xDloop@a } +\robust@def\xDloop@b#1{\expandafter\xDloop@a\expandafter{#1}} \robust@def\xDloop@a#1#2#3{% - \getDlooptype - \pushfunctions{#2,\if@useempty,\if@breakloop,\Dlooptype}\cpt@depth + \pushfunctions + {#2,\if@useempty,\if@breakloop,\if@robdes}\cpt@depth \@breakloopfalse - \cpt@Dloop@a#1,\cpt@nil,{#3}% - \popfunctions{#2,\if@useempty,\if@breakloop,\Dlooptype}\cpt@depth + \cpt@Dloop@a#1,\cpt@nil,\cpt@unique#2{#3}% + \popfunctions + {#2,\if@useempty,\if@breakloop,\if@robdes}\cpt@depth + \UseNormalDespace } -\robust@def\cpt@Dloop@a{% +\robust@def*\cpt@Dloop@a{% \if@boolTF{@breakloop}{% - \defpass\gobble@remainder##1&##2##3{}% + \defpass\gobble@remainder##1\cpt@unique##2##3{}% }{% \cpt@Dloop@b.% }% } -\robust@def\cpt@Dloop@b#1,#2#4{% +\robust@def\cpt@Dloop@b#1,#2\cpt@unique#3#4{% \edef#3{\expandcsonce{\remove@to@dot#1}}% - \ifxF#3\cpt@nnil{% - \ifcsemptyTF#3{% + \ifxTF#3\cpt@nnil{}{% + \ifcsnullTF#3{% \if@useempty#4\relax\fi }{% - \@nameuse{\ifnum\Dlooptype=\z@ normal\else robust\fi + \usecsn{\if@robdes robust\else normal\fi @despacecontent}#3% #4\relax }% - \cpt@Dloop@a#2{#4}% + \cpt@Dloop@a#2\cpt@unique#3{#4}% }% } \robust@def*\foreachitem{\cpt@testst\cpt@foreach} \newcommand\cpt@foreach[4][,]{% - \pushfunctions{#3,\if@useempty,\if@breakloop, - \if@userobustdespace}\cpt@depth + \pushfunctions + {#3,\if@useempty,\if@breakloop,\if@robdes}\cpt@depth \@breakloopfalse \ifcpt@st\let#3#2\else\edef#3{\unexpanded{#2}}\fi \long\def\cpt@foreach@a{% \if@boolTF{@breakloop}{% - \defpass\gobble@remainder####1&####2####3{}% + \defpass\gobble@remainder####1\cpt@unique####2####3{}% }{% \cpt@foreach@b.% }% }% - \long\def\cpt@foreach@b##1#1##2&##3##4{% + \long\def\cpt@foreach@b##1#1##2\cpt@unique##3##4{% \edef##3{\expandcsonce{\remove@to@dot##1}}% - \ifxF##3\cpt@nnil{% - \ifcsemptyTF##3{% + \ifxTF##3\cpt@nnil{}{% + \ifcsnullTF##3{% \if@useempty##4\relax\fi }{% - \@nameuse{\if@userobustdespace robust\else normal\fi + \usecsn{\if@robdes robust\else normal\fi @despacecontent}##3% ##4\relax }% - \cpt@foreach@a##2&##3{##4}% + \cpt@foreach@a##2\cpt@unique##3{##4}% }% }% - \expandafter\cpt@foreach@a#3#1\cpt@nil#1{#4}% - \popfunctions{#3,\if@useempty,\if@breakloop, - \if@userobustdespace}\cpt@depth + \expandafter\cpt@foreach@a#3#1\cpt@nil#1\cpt@unique#3{#4}% + \popfunctions + {#3,\if@useempty,\if@breakloop,\if@robdes}\cpt@depth \UseNormalDespace } \robust@def*\oneDfifo{\cpt@teststoptb\cpt@oneDfifo} @@ -673,24 +708,27 @@ \declarefifoparser{#1}% \pushnumber\oneDfifodepth \ifnum\oneDfifodepth>\@ne\cpt@toodeep\oneDfifo1\fi + \let\on@currlevel\@secondoftwo \@breakloopfalse \begingroup \if@boolTF{cpt@st}% - {\let\cpt@tempa#2}{\edef\cpt@tempa{\unexpanded{#2}}}% + {\let\reserved@a#2}{\edef\reserved@a{\unexpanded{#2}}}% \expandafter\endgroup\expandafter\cpt@fifoloop@a - \cpt@tempa#1\cpt@nil#1% + \reserved@a#1\cpt@nil#1% \popnumber\oneDfifodepth + \let\on@currlevel\rc@on@currlevel } \robust@def*\xDfifo{\cpt@teststoptb\cpt@xDfifo} \robust@def*\cpt@xDfifo[#1]#2{% \declarefifoparser{#1}% \pushfunctions{\fifo@do,\if@breakloop,\if@useempty}\cpt@depth + \let\curr@level\cpt@depth \@breakloopfalse \begingroup \if@boolTF{cpt@st}% - {\let\cpt@tempa#2}{\edef\cpt@tempa{\unexpanded{#2}}}% + {\let\reserved@a#2}{\edef\reserved@a{\unexpanded{#2}}}% \expandafter\endgroup\expandafter\cpt@fifoloop@a - \cpt@tempa#1\cpt@nil#1% + \reserved@a#1\cpt@nil#1% \popfunctions{\fifo@do,\if@breakloop,\if@useempty}\cpt@depth } \robust@def*\declarefifoparser#1{% @@ -703,34 +741,46 @@ }% \protected\def\cpt@fifoloop@b##1#1{% \edef\fifo@arg{\expandcsonce{\@gobble##1}}% - \ifxF\fifo@arg\cpt@nnil{% - \ifcsemptyTF\fifo@arg{% - \if@boolT{@useempty}{\fifo@do{}\relax}% + \ifxTF\fifo@arg\cpt@nnil{}{% + \ifcsnullTF\fifo@arg{% + \if@boolTF{@useempty}{\on@currlevel{}\fifo@do{}\relax}{}% }{% - \expandafter\fifo@do\expandafter{\fifo@arg}\relax + \cptexpandargonce{\on@currlevel{}\fifo@do}\fifo@arg\relax }% \cpt@fifoloop@a }% }% } +\robust@def*\simplefifoloop#1{\cpt@simplefifoloop#1,\cpt@nil,} +\robust@def*\cpt@simplefifoloop#1,{% + \edef\fifo@arg{\unexpanded{#1}}% + \ifx\fifo@arg\cpt@nnil\else + \fifo@do{#1}\relax + \expandafter\cpt@simplefifoloop + \fi +} +\let\rc@on@currlevel\on@currlevel \robust@def*\oneDsiso{\cpt@testst\cpt@oneDsiso} \robust@def\cpt@oneDsiso#1{% \pushnumber\oneDsisodepth \ifnum\oneDsisodepth>\@ne\cpt@toodeep\oneDsiso1\fi + \let\on@currlevel\@secondoftwo \@breakloopfalse \begingroup \if@boolTF{cpt@st}% - {\let\cpt@tempa#1}{\edef\cpt@tempa{\unexpanded{#1}}}% - \expandafter\endgroup\expandafter\cpt@sisoloop\cpt@tempa\sisorepeat + {\let\reserved@a#1}{\edef\reserved@a{\unexpanded{#1}}}% + \expandafter\endgroup\expandafter\cpt@sisoloop\reserved@a\sisorepeat \popnumber\oneDsisodepth + \let\on@currlevel\rc@on@currlevel } \robust@def*\xDsiso{\cpt@testst\cpt@xDsiso} \robust@def\cpt@xDsiso#1{% \pushfunctions{\siso@do,\if@useempty,\if@breakloop}\cpt@depth + \let\curr@level\cpt@depth \@breakloopfalse \begingroup - \ifcpt@st\let\cpt@tempa#1\else\edef\cpt@tempa{\unexpanded{#1}}\fi - \expandafter\endgroup\expandafter\cpt@sisoloop\cpt@tempa\sisorepeat + \ifcpt@st\let\reserved@a#1\else\edef\reserved@a{\unexpanded{#1}}\fi + \expandafter\endgroup\expandafter\cpt@sisoloop\reserved@a\sisorepeat \popfunctions{\siso@do,\if@useempty,\if@breakloop}\cpt@depth } \robust@def*\cpt@sisoloop{% @@ -738,23 +788,30 @@ \defpass\gobble@remainder##1\sisorepeat{}% }{% \begingroup - \let\@bgroup\bgroup + \let\temp@bgroup\bgroup \let\bgroup\cpt@undefined \futurelet\next\cpt@sisol@op }% } \robust@def\cpt@sisol@op#1{% \expandafter\endgroup - \ifx\next\@bgroup\def\siso@arg{{#1}}\else\def\siso@arg{#1}\fi + \ifx\next\temp@bgroup\def\siso@arg{{#1}}\else\def\siso@arg{#1}\fi \ifblankTF{#1}{% - \if@useempty\siso@do{}\relax\fi + \if@useempty\on@currlevel{}\siso@do{}\relax\fi }{% \ifx#1\sisorepeat\sisorepeat\fi - \expandafter\siso@do\expandafter{\siso@arg}\relax + \cptexpandargonce{\on@currlevel{}\siso@do}\siso@arg\relax }% \cpt@sisoloop } -\robust@def\sisorepeat#1\cpt@sisoloop{\fi}% +\robust@def\sisorepeat#1\cpt@sisoloop{\fi} +\robust@def*\simplesisoloop#1{\cpt@simplesisoloop#1\cpt@nnil} +\robust@def*\cpt@simplesisoloop#1{% + \ifxTF#1\cpt@nnil{}{% + \siso@do{#1}\relax + \cpt@simplesisoloop + }% +} \robust@def*\csv@@parse{% \let\csv@kv@nr\z@ \cpt@teststoptb\csv@kv@parse @@ -764,8 +821,8 @@ \cpt@teststoptb\csv@kv@parse } \newcommand\csv@kv@parse[2][,]{% - \cs@let@csn\csv@kv@do{\ifnum\csv@kv@nr=\z@ csv\else kv\fi @do}% - \ifdefF\csv@kv@do{% + \letcstocsn\csv@kv@do{\ifnum\csv@kv@nr=\z@ csv\else kv\fi @do}% + \ifdefTF\csv@kv@do{}{% \cpt@err{'\string\csv@do' or '\string\kv@do' undefined}\@ehc }% \long\def\csv@tempa{% @@ -777,10 +834,11 @@ }% \long\def\csv@tempb##1#1{% \edef\csv@tempc{\expandcsonce{\remove@to@dot##1}}% - \ifxF\csv@tempc\cpt@nnil{% - \ifcsemptyTF\csv@tempc{% - \if@boolT{@useempty}{\csv@kv@do{}}\relax + \ifxTF\csv@tempc\cpt@nnil{}{% + \ifcsnullTF\csv@tempc{% + \if@boolTF{@useempty}{\on@currlevel{}\csv@kv@do{}\relax}{}% }{% + \expandafter\on@currlevel\expandafter\@empty \expandafter\csv@kv@do\expandafter{\csv@tempc}\relax }% \csv@tempa @@ -788,12 +846,14 @@ }% \if@boolTF{cpt@st}% {\let\csv@tempc#2}{\edef\csv@tempc{\unexpanded{#2}}}% - \ifcsemptyF\csv@tempc{% - \@nameuse{\ifnum\csv@kv@nr=\@ne kv\else csv\fi @@normalize}% - *[#1]\csv@tempc + \ifcsnullTF\csv@tempc{}{% + \cpt@sttrue + \usecsn{cpt@\ifnum\csv@kv@nr=\@ne kv\else csv\fi normalize}% + [#1]\csv@tempc }% \pushfunctions{\csv@kv@do,\if@useempty,\if@breakloop}\cpt@depth \@breakloopfalse + \let\curr@level\cpt@depth \expandafter\csv@tempa\csv@tempc#1\cpt@nil#1% \popfunctions{\csv@kv@do,\if@useempty,\if@breakloop}\cpt@depth } @@ -806,79 +866,131 @@ }{% \cpt@err{'\string\curr@level' undefined}\@ehc }% - \@fullxpsec + \cptexpandsecond {#1}{\noexpandcsn{\cptgobblescape#2@\cpt@rnm\curr@level}}% } \new@def\cptafterfi#1\fi{\fi#1} \new@def\cptafterelsefi#1\else#2\fi{\fi#1} \new@def\cptafterfifi#1\fi#2\fi{\fi\fi#1} -\robust@def*\cptemptify#1{\let#1\@empty} -\new@def*\ifcsemptyTF#1{% - \@nameuse{@\ifx#1\@empty first\else second\fi oftwo}% +\robust@def*\emptify#1{\let#1\@empty} +\robust@def*\gemptify#1{\global\let#1\@empty} +\robust@def*\genemptify{\cpt@teststpm\cpt@genemptify} +\def\cpt@genemptify#1{% + \ifcpt@pm\global\fi\ifcpt@st\else\long\fi\def#1{}% +} +\robust@def*\emptifycsn{\aftercsname\emptify} +\robust@def*\gemptifycsn{\global\aftercsname\emptify} +\robust@def*\emptifycsset#1{% + \normaloneDloop{#1}\cpt@tempa{% + \expandafter\ifescapedTF\expandafter{\cpt@tempa}{% + \expandafter\def\cpt@tempa{}% + }{% + \cpt@err{Can't emptify unescaped macro}\@ehc + }% + }% } -\robust@def*\cptemptifycsset#1{% +\robust@def*\cptonlypreamble#1{% + \begingroup + \def\cpt@resa{}% \normaloneDloop{#1}\cpt@tempa{% - \expandafter\def\cpt@tempa{}% - }% -} -\new@def*\ifcsemptyFT#1{\ifcsemptyTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\ifcsemptyT#1{\ifcsemptyTF{#1}\@firstofone\@gobble} -\new@def*\ifcsemptyF#1{\ifcsemptyTF{#1}\@gobble\@firstofone} -\new@def*\oifcsemptyTF#1{\expandafter\ifcsemptyTF#1} -\new@def*\oifcsemptyFT#1{\expandafter\ifcsemptyFT#1} -\new@def*\oifcsemptyT#1{\expandafter\ifcsemptyT#1} -\new@def*\oifcsemptyF#1{\expandafter\ifcsemptyF#1} -\new@def*\ifcsnemptyTF#1{% - \ifcsndefTF{#1}{% - \expandafter\ifx\csname#1\endcsname\@empty - \expandafter\@firstoftwo - \else - \expandafter\@secondoftwo - \fi - }{% + \ifcsnullTF\cpt@tempa{}{% + \simpleexpandarg\ifescapedFT\cpt@tempa{% + \cpt@err{'\expandcsonce\cpt@tempa' not a command}\@ehc + }{% + \simpleexpandarg\ifsingletokenTF\cpt@tempa{% + \xifinsetTF{,\expandcsonce\cpt@tempa,} + {,\expandcsonce\cpt@resa,}{% + \cpt@warn{Command '\expandcsonce\cpt@tempa' multiply + \MsgBrk submitted to \string\cptonlypreamble}% + }{% + \expandafter\@onlypreamble\cpt@tempa + \cptaddtocommalist\cpt@resa\cpt@tempa + }% + }{% + \cpt@err{Invalid multiple arguments + '\expandcsonce\cpt@tempa'}\@ehc + }% + }% + }% + }% + \endgroup +} +\newletcs\IfFileExistsTF\IfFileExists +\new@def*\IfFileExistsFT#1{\IfFileExists{#1}\@secondoftwo\@firstoftwo} +\new@def*\ifcsnullTF#1{% + \@nameuse{@\expandafter\ifx\expandafter\cpt@unique + \@gobble#1.\cpt@unique second\else first\fi oftwo}% + {\@nameuse{@\ifx#1\@empty first\else second\fi oftwo}}% + \@secondoftwo +} +\new@def*\ifcsnullFT#1{\ifcsnullTF{#1}\@secondoftwo\@firstoftwo} +\new@def*\oifcsnullTF#1{\expandafter\ifcsnullTF#1} +\new@def*\oifcsnullFT#1{\expandafter\ifcsnullFT#1} +\new@def*\ifcsnnullTF#1{% + \ifblankTF{#1}{% \@secondoftwo + }{% + \ifcsndefTF{#1}{% + \expandafter\ifx\csname#1\endcsname\@empty + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + }{% + \@secondoftwo + }% }% } -\new@def*\ifcsnemptyFT#1{\ifcsnemptyTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\ifcsnemptyT#1{\ifcsnemptyTF{#1}\@firstofone\@gobble} -\new@def*\ifcsnemptyF#1{\ifcsnemptyTF{#1}\@gobble\@firstofone} +\new@def*\ifcsnnullFT#1{\ifcsnnullTF{#1}\@secondoftwo\@firstoftwo} \new@def*\ifdefnotnullTF#1{% - \ifdefTF{#1}{\ifcsemptyTF{#1}{\@secondoftwo}% - {\@firstoftwo}}{\@secondoftwo}% + \ifdefTF{#1}{\ifcsnullTF{#1}\@secondoftwo\@firstoftwo}\@secondoftwo } \new@def*\ifdefnotnullFT#1{\ifdefnotnullTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\ifdefnotnullT#1{\ifdefnotnullTF{#1}\@firstofone\@gobble} -\new@def*\ifdefnotnullF#1{\ifdefnotnullTF{#1}\@gobble\@firstofone} +\robust@def*\advexpandarg#1#2{% + \ifsingletokenTF{#1}{% + \expandafter#1\expandafter{#2}% + }{% + \LTS@err{Argument \detokenize{#1} has more than one token}\@ehc + }% +} +\new@def*\simpleexpandarg#1#2{\expandafter#1\expandafter{#2}} \new@def*\expandcsonce#1{\unexpanded\expandafter{#1}} -\new@def*\expandcsnonce#1{\cptthreexp\expandcsonce\@nameuse{#1}} +\new@def*\expandcsnonce#1{\cptthreexp\expandcsonce\usecsn{#1}} \new@def*\noexpandcsn#1{\expandcsonce{\csname#1\endcsname}} -\new@def*\cptxpdetok#1{\detokenize\expandafter{#1}} +\let\cptmakecs\noexpandcsn +\new@def*\cptoxdetok#1{\detokenize\expandafter{#1}} +\new@def*\cpttxdetok#1{\detokenize\cptthreexp{#1}} +\new@def*\cptsxdetok#1{\detokenize\cptsevenxp{#1}} \robust@def\cptpassexpanded#1{% \begingroup\protected@edef\x{\endgroup#1}\x } +\let\cptexpanded\cptpassexpanded \robust@def\cptpassunexpanded#1{\begingroup\long\def\x{\endgroup#1}\x} \robust@def\defpass#1#2#{\afterassignment#1\long\def#1#2} \robust@def\edefpass#1#2#{\afterassignment#1\long\edef#1#2} -\robust@def*\cptfullexpandsecond#1#2{\cptpassexpanded{\unexpanded{#1}#2}} -\robust@def*\cptexpandsecondonce#1#2{% - \cptpassexpanded{\unexpanded{#1}\expandcsonce{#2}}} -\robust@def*\cptfullexpandarg#1#2{\cptpassexpanded{\unexpanded{#1}{#2}}} +\robust@def*\cptexpandarg#1#2{\cptpassexpanded{\unexpanded{#1}{#2}}} +\let\cptexpandargbraced\cptexpandarg \robust@def*\cptexpandargonce#1#2{% \cptpassexpanded{\unexpanded{#1}{\expandcsonce{#2}}}% } -\robust@def*\protected@xptwoargs#1#2#3{% - \begingroup - \protected@edef\x{\endgroup\unexpanded{#1}{#2}{#3}}\x +\robust@def*\cptexpandsecond#1#2{\cptpassexpanded{\unexpanded{#1}#2}} +\let\cptexpandargunbraced\cptexpandsecond +\robust@def*\cptexpandsecondonce#1#2{% + \cptpassexpanded{\unexpanded{#1}\expandcsonce{#2}}% +} +\robust@def*\cptexpandsecondarg#1#2#3{% + \cptpassexpanded{\unexpanded{#1#2}{#3}}% +} +\robust@def*\cptexpandsecondargonce#1#2#3{% + \cptpassexpanded{\unexpanded{#1#2}{\expandcsonce{#3}}}% +} +\robust@def*\cptexpandtwoargs#1#2#3{% + \cptpassexpanded{\unexpanded{#1}{#2}{#3}}% } \robust@def*\cptexpandtwoargsonce#1#2#3{% - \cptpassexpanded{% - \unexpanded{#1}{\expandcsonce{#2}}{\expandcsonce{#3}}}% + \cptpassexpanded + {\unexpanded{#1}{\expandcsonce{#2}}{\expandcsonce{#3}}}% } -\letnewcmd\@xpargox\cptexpandargonce -\letnewcmd\@fullxparg\cptfullexpandarg -\letnewcmd\@xpsecox\cptexpandsecondonce -\letnewcmd\@fullxpsec\cptfullexpandsecond -\letnewcmd\@xptwoargox\cptexpandtwoargsonce \robust@def*\StyleFileRCSInfo$#1 #2 #3 #4 #5 #6 #7 #8 ${% \def\cpt@filedate{#4}% \def\cpt@fileversion{v#3}% @@ -896,10 +1008,10 @@ } \robust@def*\SetStyleFileMessages{% \begingroup - \catcode`\ =9\catcode`\^^I=9% - \edef\cpt@tempa{\@xp\@carcube\@currname\@nil @}% - \def\cpt@tempb{\@testopt{\@xp\endgroup\cpt@SetStyleFileMessages}}% - \@xp\cpt@tempb\@xp{\cpt@tempa}% + \catcode`\ =9\catcode`\^^I=9\relax + \edef\cpt@tempa{\expandafter\@carcube\@currname\@nil @}% + \def\cpt@tempb{\@testopt{\expandafter\endgroup\cpt@SetStyleFileMessages}}% + \expandafter\cpt@tempb\expandafter{\cpt@tempa}% } \robust@def*\cpt@SetStyleFileMessages[#1]#2#3#4{% \begingroup @@ -953,41 +1065,54 @@ }% } \new@def*\ifboolFT#1{\ifboolTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\ifboolT#1{\ifboolTF{#1}\@firstofone\@gobble} -\new@def*\ifboolF#1{\ifboolTF{#1}\@gobble\@firstofone} \new@def*\ifbooleanTF#1#{\ifboolTF{#1}} \new@def*\if@boolTF#1{% - \@nameuse{if#1}\expandafter\@firstoftwo\else + \usecsn{if#1}\expandafter\@firstoftwo\else \expandafter\@secondoftwo\fi } \new@def*\if@boolFT#1{\if@boolTF{#1}\@secondoftwo\@firstoftwo} -\new@def*\if@boolT#1{\if@boolTF{#1}\@firstofone\@gobble} -\new@def*\if@boolF#1{\if@boolTF{#1}\@gobble\@firstofone} \new@def*\ifnumTF#1#{% - \@nameuse{@\ifnum#1first\else second\fi oftwo}% + \usecsn{@\ifnum#1first\else second\fi oftwo}% } -\new@def*\ifnumT#1#{\ifnumTF#1{\@firstofone}\@gobble} -\new@def*\ifnumF#1#{\ifnumTF#1{\@gobble}\@firstofone} -\new@def*\ifnumFT#1#{\@nameuse{@\ifnumTF#1{second}{first}oftwo}} +\new@def*\ifnumFT#1#{\usecsn{@\ifnumTF#1{second}{first}oftwo}} +\new@def*\ifoddTF#1#{% + \usecsn{@\ifodd#1\@empty first\else second\fi oftwo}% +} +\new@def*\ifoddFT#1#{\usecsn{@\ifoddTF#1{second}{first}oftwo}} \robust@def*\cptnumdef#1#2{\edef#1{\the\numexpr#2}} \robust@def*\cptdimdef#1#2{\edef#1{\the\dimexpr#2}} \robust@def*\cptnumadd#1#2{\edef#1{\the\numexpr#1+#2}} \robust@def*\cptdimadd#1#2{\edef#1{\the\dimexpr#1+#2}} -\new@edef*\@leftbracechar{\@xp\@car\string{\@nil\iffalse}\fi} -\long\def\cptstrcmp#1#2{% - \ifnum\pdfstrcmp{#1}{#2}=\z@\@xp\@firstoftwo\else - \@xp\@secondoftwo\fi +\new@edef*\@leftbracechar{\expandafter\@car\string{\@nil\iffalse}\fi} +\new@def\cptstrcmp#1#2{% + \ifnum\pdfstrcmp{#1}{#2}=\z@\expandafter\@firstoftwo\else + \expandafter\@secondoftwo\fi } \new@def\ifstrcmpTF#1#2{% \cptstrcmp{\detokenize{#1}}{\detokenize{#2}}% } \new@def\ifstrcmpFT#1#2{\ifstrcmpTF{#1}{#2}\@secondoftwo\@firstoftwo} -\new@def\ifstrcmpT#1#2{\ifstrcmpTF{#1}{#2}\@firstofone\@gobble} -\new@def\ifstrcmpF#1#2{\ifstrcmpTF{#1}{#2}\@gobble\@firstofone} +\robust@def\oifstrcmpTF#1#2{\cptexpandtwoargsonce\ifstrcmpTF{#1}{#2}} +\robust@def\oifstrcmpFT#1#2{\cptexpandtwoargsonce\ifstrcmpFT{#1}{#2}} +\robust@def\xifstrcmpTF#1#2{\cptexpandtwoargs\ifstrcmpTF{#1}{#2}} +\robust@def\xifstrcmpFT#1#2{\cptexpandtwoargs\ifstrcmpFT{#1}{#2}} +\robust@def\ifstreqTF#1#2{% + \begingroup + \robust@despace{#1}\cpt@tempa + \robust@despace{#2}\cpt@tempb + \aftercsname\endgroup{@\ifnum\pdfstrcmp + {\cptoxdetok\cpt@tempa}{\cptoxdetok\cpt@tempb}% + =\z@ first\else second\fi oftwo}% +} +\robust@def\ifstreqFT#1#2{\ifstreqTF{#1}{#2}\@secondoftwo\@firstoftwo} +\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}} +\robust@def\xifstreqFT#1#2{\cptexpandtwoargs\ifstreqFT{#1}{#2}} \long\def\ifbracedTF#1{% - \cptstrcmp{\detokenize\@xp{\@gobble#1.}}{}\@secondoftwo{% - \cptstrcmp{\detokenize\@xp{\@gobble#1}}{}{% - \cptstrcmp{\@xp\cpt@car\detokenize{#1}\car@nil}{\@leftbracechar}% + \cptstrcmp{\detokenize\expandafter{\@gobble#1.}}{}\@secondoftwo{% + \cptstrcmp{\detokenize\expandafter{\@gobble#1}}{}{% + \cptstrcmp{\expandafter\cpt@car\detokenize{#1}\car@nil}{\@leftbracechar}% \@firstoftwo\@secondoftwo }{% \@secondoftwo @@ -995,35 +1120,31 @@ }% } \newcommand\ifbracedFT[1]{\ifbracedTF{#1}\@secondoftwo\@firstoftwo} -\newcommand\ifbracedT[1]{\ifbracedTF{#1}\@firstofone\@gobble} -\newcommand\ifbracedF[1]{\ifbracedTF{#1}\@gobble\@firstofone} \long\def\ifleftbracedTF#1{% - \cptstrcmp{\detokenize\@xp{\@gobble#1.}}{}\@secondoftwo{% - \cptstrcmp{\@xp\@car\detokenize{#1}\@nil}{\@leftbracechar}% + \cptstrcmp{\detokenize\expandafter{\@gobble#1.}}{}\@secondoftwo{% + \cptstrcmp{\expandafter\cpt@car\detokenize{#1}\car@nil}{\@leftbracechar}% \@firstoftwo\@secondoftwo }% } \new@def\ifxTF#1#2{% - \@nameuse{@\ifx#1#2\@empty first\else second\fi oftwo}% + \usecsn{@\ifx#1#2\@empty first\else second\fi oftwo}% } \new@def\ifxFT#1#2{\ifxTF{#1}{#2}\@secondoftwo\@firstoftwo} -\new@def\ifxT#1#2{\ifxTF{#1}{#2}\@firstofone\@gobble} -\new@def\ifxF#1#2{\ifxTF{#1}{#2}\@gobble\@firstofone} \new@def*\ifcptdefeqTF#1#2{% \ifdefTF{#1}{% \ifdefTF{#2}{% - \@nameuse{@\ifx#1#2first\else second\fi of oftwo}% + \usecsn{@\ifx#1#2first\else second\fi of oftwo}% }\@secondoftwo }\@secondoftwo } \new@def\ifcatTF#1#{% - \@nameuse{@\ifcat#1first\else second\fi oftwo}% + \usecsn{@\ifcat#1first\else second\fi oftwo}% } \new@def\ifcharcmpTF#1#2{% - \ifcptonetokenTF{#1}{% - \ifcptonetokenTF{#2}{% - \@nameuse{@\if\detokenize\@xp{\cpt@rnm\@xp - \cptswap\@xp{\cpt@rnm-`\q#2}{-`\q#1}}% + \ifsingletokenTF{#1}{% + \ifsingletokenTF{#2}{% + \usecsn{@\if\detokenize\expandafter{\cpt@rnm\expandafter + \cptswap\expandafter{\cpt@rnm-`\q#2}{-`\q#1}}% first\else second\fi oftwo}% }{% \cpt@err{More than one token in '\detokenize{#2}'}\@ehc @@ -1035,18 +1156,48 @@ }% } \new@def\ifcharcmpFT#1#2{\ifcharcmpTF{#1}{#2}\@secondoftwo\@firstoftwo} -\new@def\ifcharcmpT#1#2{\ifcharcmpTF{#1}{#2}\@firstofone\@gobble} -\new@def\ifcharcmpF#1#2{\ifcharcmpTF{#1}{#2}\@gobble\@firstofone} -\new@def\ifcptonetokenTF#1{% - \ifblankTF{#1}\@secondoftwo{% +\new@def\ifexpandableTF#1#2#3{% + \cpt@rnm\ifleftbracedTF{#1}\@secondoftwo{% + \ifblankTF{#1}\@secondoftwo{\expandafter\ifx\noexpand#1#1% + \expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}}% + {0 #2}{0 #3}% +} +\new@def*\iffirstisspaceTF#1{% + \long\def\iffirstisspaceTF##1##2##3{% + \cpt@rnm\usecsn{@\ifblankTF{##1}{second}% + {\cpt@iffirstisspace.##1#1\@nnil}oftwo}{0#1##2}{0#1##3}% + }% +} +\iffirstisspaceTF{ } +\new@def\cpt@iffirstisspace#1 {% + \expandafter\ifblankTF\expandafter{\@gobble#1}{first}{second}% + \remove@to@nnil +} +\new@def\ifsingletokenTF#1#2#3{% + \cpt@rnm\ifblankTF{#1}\@secondoftwo{% \ifbracedTF{#1}\@secondoftwo{% - \expandafter\ifstremptyTF\expandafter{\@gobble#1}% + \iffirstisspaceTF{#1}{% + \expandafter\ifblankTF\expandafter{\@gobblespace#1}% + }{% + \expandafter\ifblankTF\expandafter{\@secondoftwo#1{}}% + }% + \@firstoftwo\@secondoftwo }% - }% + }{0 #2}{0 #3}% +} +\robust@def*\ifsingletokenFT#1{% + \ifsingletokenTF{#1}\@secondoftwo\@firstoftwo } \robust@def*\cpt@checklistparser#1#2{% - \ifcptonetokenTF{#1}% - {#2}{\cpt@err{Invalid list parser '#1'}\@ehc}% + \ifsingletokenTF{#1}{% + \xifinsetTF{\detokenize{#1}}{\detokenize{,;:/+-|*&}}{% + #2 + }{% + \cpt@err{Invalid list parser '#1'}\@ehc + }% + }{% + \cpt@err{Invalid list parser '#1'}\@ehc + }% } \robust@def\exitgroupdef#1{% \cptpassexpanded{\endgroup\edef @@ -1054,30 +1205,36 @@ } \robust@def*\cptaftergroup#1{% \advance\@tempcnta\@ne - \csn@xdef{cpt@exitgroup@\cpt@rnm\@tempcnta}{% - \global\undef@csn{cpt@exitgroup@\cpt@rnm\@tempcnta}% - \unexpanded\ifnullF{#1}\expandafter{#1}% + \csn@xdef{cpt@aftergroup@\cpt@rnm\@tempcnta}{% + \gundefcsn{cpt@aftergroup@\cpt@rnm\@tempcnta}% + \unexpanded\ifnullTF{#1}{}\expandafter{#1}% }% - \cptaftercs\aftergroup{cpt@exitgroup@\cpt@rnm\@tempcnta}% + \aftercsname\aftergroup{cpt@aftergroup@\cpt@rnm\@tempcnta}% } \robust@def\cptafterassignment#1{% \begingroup \advance\@tempcnta\@ne \csn@xdef{cpt@afterassignment@\cpt@rnm\@tempcnta}{% - \global\undef@csn{cpt@afterassignment@\cpt@rnm\@tempcnta}% - \unexpanded\ifnullF{#1}\expandafter{#1}% + \gundefcsn{cpt@afterassignment@\cpt@rnm\@tempcnta}% + \unexpanded\ifnullTF{#1}{}\expandafter{#1}% }% - \expandafter\endgroup\expandafter\afterassignment - \csname cpt@afterassignment@\cpt@rnm\@tempcnta\endcsname + \aftercsname{\endgroup\afterassignment}{% + cpt@afterassignment@\cpt@rnm\@tempcnta}% } -\robust@def\cptdefxppass#1#2#{% - \cptafterassignment{\expandafter#1}\def#1#2% +\robust@def*\cptexpandmacro#1#2{% + \ifcptmacroTF{#1}{% + \ifexpandableTF{#1}{% + \simpleexpandarg\cptexpandmacro{#1}% + }{% + \edef#2{\unexpanded{#1}}% + }% + }{% + \edef#2{\unexpanded{#1}}% + }% } -\robust@def\defsec@fir#1#2{\edef#2{\unexpanded{#1}}} \robust@def\cpt@ifnextchar#1#2#3{% \kernel@ifnextchar\bgroup - {\kernel@ifnextchar{#1}{#2}{#3}}% - {\cpt@ifn@xtchar{#1}{#2}{#3}}% + {\kernel@ifnextchar{#1}{#2}{#3}}{\cpt@ifn@xtchar{#1}{#2}{#3}}% } \robust@def\cpt@ifn@xtchar#1#2#3#4{% \csname @\if\detokenize{#1#4}first\else @@ -1085,11 +1242,13 @@ } \robust@def\cpt@testopt#1#2{\cpt@ifnextchar[{#1}{#1[{#2}]}} \robust@def*\cpt@ifbrack#1#2{\cpt@ifnextchar[{#1}{#2}} -\new@def*\cpt@xtestopt#1#2#3{\cpt@xifbrack#1&[&{#2#1}{#2[{#3}]{#1}}} -\new@def*\cpt@xifbrack#1[#2#{% - \@nameuse{@\ifnullTF{#1#2}{first}{second}oftwo}% +\new@def*\cpt@xtestopt#1#2#3{% + \cpt@xifbrack#1\cpt@unique[\cpt@unique{#2#1}{#2[{#3}]{#1}}% } -\robust@def\cpt@testparenopt#1#2{\cpt@ifnextchar({#1}{#1({#2})}} +\new@def*\cpt@xifbrack#1[#2\cpt@unique#3#{% + \usecsn{@\ifnullTF{#1#2}{first}{second}oftwo}% +} +\robust@def\cpt@testpnopt#1#2{\cpt@ifnextchar({#1}{#1({#2})}} \robust@def\cpt@ifstar#1{\cpt@ifnextchar*{\@firstoftwo{#1}}} \robust@def\cpt@ifplus#1{\cpt@ifnextchar+{\@firstoftwo{#1}}} \robust@def\cpt@ifprime#1{\cpt@ifnextchar'{\@firstoftwo{#1}}} @@ -1100,48 +1259,76 @@ \robust@def\cpt@teststpm#1{\cpt@testst{\cpt@testpm{#1}}} \robust@def\cpt@teststopta#1{\cpt@testst{\cpt@testopt{#1}{}}} \robust@def\cpt@teststoptb#1{\cpt@testst{\cpt@testopt{#1}{,}}} -\new@def*\cptifstrcase#1{\cpt@xtestopt{#1}\cpt@ifstrcase{}} +\new@def*\ifcptstrcase#1{\cpt@xtestopt{#1}\cpt@ifstrcase{}} \new@def\cpt@ifstrcase[#1]#2#3{% \expandafter\cptswapfirstbraced\expandafter{#2}% {\cpt@ifstrc@se#3\cpt@mil\cpt@mil\cpt@nil}{#1}% } \new@def\cpt@ifstrc@se#1#2#3\cpt@nil#4#5{% - \ifstremptyTF{#3}{#5}{% + \ifnullTF{#3}{#5}{% \ifstrcmpTF{#1}{#4}{#2}{% \cpt@ifstrc@se#3\cpt@nil{#4}{#5}% }% }% } -\robust@def\ifinsetTF#1#2{% +\robust@def\cptinset#1#2{% \begingroup \def\in@@##1#1##2##3\in@@{\endgroup \ifx##2\in@\in@false\else\in@true\fi }% \in@@#2{\in@@}#1\in@\in@@ - \ifin@\@xp\@firstoftwo\else\@xp\@secondoftwo\fi +} +\robust@def\ifinsetTF#1#2{% + \cptinset{#1}{#2}% + \@nameuse{@\ifin@ first\else second\fi oftwo}% } \robust@def\ifinsetFT#1#2{\ifinsetTF{#1}{#2}\@secondoftwo\@firstoftwo} -\robust@def\ifinsetT#1#2{\ifinsetTF{#1}{#2}\@firstofone\@gobble} -\robust@def\ifinsetF#1#2{\ifinsetTF{#1}{#2}\@gobble\@firstofone} \robust@def\oifinsetTF#1#2{% \begingroup \edef\cpt@tempa{{\expandcsonce{#1}}{\expandcsonce{#2}}}% \expandafter\endgroup\expandafter\ifinsetTF\cpt@tempa } \robust@def\oifinsetFT#1#2{\oifinsetTF{#1}{#2}\@secondoftwo\@firstoftwo} -\robust@def\oifinsetT#1#2{\oifinsetTF{#1}{#2}\@firstofone\@gobble} -\robust@def\oifinsetF#1#2{\oifinsetTF{#1}{#2}\@gobble\@firstofone} \robust@def\xifinsetTF#1#2{% \begingroup \protected@edef\cpt@tempa{{#1}{#2}}% \expandafter\endgroup\expandafter\ifinsetTF\cpt@tempa } \robust@def\xifinsetFT#1#2{\xifinsetTF{#1}{#2}\@secondoftwo\@firstoftwo} -\robust@def\xifinsetT#1#2{\xifinsetTF{#1}{#2}\@firstofone\@gobble} -\robust@def\xifinsetF#1#2{\xifinsetTF{#1}{#2}\@gobble\@firstofone} -\robust@def*\kill@one@element{\cpt@testopt\cpt@killoneelement{,}} +\robust@def*\cptaddtolist{\cpt@teststoptb\cpt@addtolist} +\robust@def\cpt@addtolist[#1]#2#3{% + \if@checklp\cpt@checklistparser{#1}\relax\fi + \begingroup + \def\cpt@tempa{\endgroup + \ifdefTF#2{% + \ifcpt@st + \protected@edef#2{\ifcsnullTF#2{}{\expandcsonce#2#1}#3}% + \else + \edef#2{\ifcsnullTF#2{}{\expandcsonce#2#1}\unexpanded{#3}}% + \fi + }{% + \ifcpt@st + \protected@edef#2{#3}% + \else + \edef#2{\unexpanded{#3}}% + \fi + }% + }% + \ifblankTF{#3}{\if@useempty\cpt@tempa\else\endgroup\fi}% + \cpt@tempa +} +\robust@def*\cptaddtocommalist#1#2{% + \ifdefTF{#1}{% + \xdef#1{% + \ifcsnullTF#1{}{\expandcsonce{#1},}\expandcsonce{#2}% + }% + }{% + \xdef#1{\expandcsonce{#2}}% + }% +} +\robust@def*\cptkilloneelement{\cpt@testopt\cpt@killoneelement{,}} \robust@def\cpt@killoneelement[#1]#2#3{% - \if@checklistparser\cpt@checklistparser{#1}\relax\fi + \if@checklp\cpt@checklistparser{#1}\relax\fi \begingroup \@onelevel@sanitize#3% \edef\cpt@rsvda{\detokenize{#2}}% @@ -1154,49 +1341,132 @@ \exitgroupdef#3% \cptscantokens#3% } -\def\cptkillelements{\cpt@testopt\cpt@killelements{,}} -\def\cpt@killelements[#1]#2#3{% - \def\kill@tempa{#2}% - \csv@@normalize*\kill@tempa - \csv@@normalize*#3% - \@checklistparserfalse - \def\fifo@do##1{\cpt@killoneelement[#1]{##1}#3}% - \oneDfifo*\kill@tempa - \undef@cs\kill@tempa - \@checklistparsertrue -} - -\def\remove@one@element{\cpt@testopt\cpt@removeoneelement{,}} -\def\cpt@removeoneelement[#1]#2#3{% - \if@checklistparser\cpt@checklistparser{#1}\relax\fi +\robust@def*\cptkillelements{\cpt@testopt\cpt@killelements{,}} +\robust@def\cpt@killelements[#1]#2#3{% + \edef\kill@tempa{\unexpanded{#2}}% + \cpt@sttrue\cpt@csvnormalize[#1]\kill@tempa + \cpt@sttrue\cpt@csvnormalize[#1]#3% + \pushfunctions\if@checklp\cpt@depth + \@checklpfalse + \long\def\fifo@do##1{\cpt@killoneelement[#1]{##1}#3}% + \expandafter\simplefifoloop\expandafter{\kill@tempa}% + \undefcs\kill@tempa + \popfunctions\if@checklp\cpt@depth +} +\robust@def*\cptremoveoneelement{\cpt@testopt\cpt@removeoneelement{,}} +\robust@def\cpt@removeoneelement[#1]#2#3{% + \if@checklp\cpt@checklistparser{#1}\relax\fi \begingroup \def\cpt@removeone##1#1#2#1##2\remove@nil{% \gdef#3{##1#1##2}% - \xifinsetT{\remove@nil#1}{\remove@nil\expandcsonce{#3}}{% + \xifinsetFT{\remove@nil#1}{\remove@nil\expandcsonce{#3}}{}{% \def\cpt@removeone#1####1\remove@nil{\gdef#3{####1}}% \expandafter\cpt@removeone#3\remove@nil }% - \xifinsetT{#1\remove@nil}{\expandcsonce{#3}\remove@nil}{% + \xifinsetFT{#1\remove@nil}{\expandcsonce{#3}\remove@nil}{}{% \def\cpt@removeone####1#1\remove@nil{\gdef#3{####1}}% \expandafter\cpt@removeone#3\remove@nil }% }% - \xifinsetT{#1\unexpanded{#2}#1}{#1\expandcsonce{#3}#1}{% + \xifinsetFT{#1\unexpanded{#2}#1}{#1\expandcsonce{#3}#1}{}{% \protected\def\remove@nil{}% \expandafter\cpt@removeone\expandafter#1#3#1\remove@nil }% \endgroup } -\def\cptremoveelements{\cpt@testopt\cpt@removeelements{,}} -\def\cpt@removeelements[#1]#2#3{% - \def\remove@tempa{#2}% - \csv@@normalize*\remove@tempa - \csv@@normalize*#3% - \@checklistparserfalse - \def\fifo@do##1{\cpt@removeoneelement[#1]{##1}#3}% - \oneDfifo*\remove@tempa - \undef@cs\remove@tempa - \@checklistparsertrue +\robust@def*\cptremoveelements{\cpt@testopt\cpt@removeelements{,}} +\robust@def\cpt@removeelements[#1]#2#3{% + \edef\remove@tempa{\unexpanded{#2}}% + \cpt@sttrue\cpt@csvnormalize[#1]\remove@tempa + \cpt@sttrue\cpt@csvnormalize[#1]#3% + \pushfunctions\if@checklp\cpt@depth + \@checklpfalse + \long\def\fifo@do##1{\cpt@removeoneelement[#1]{##1}#3}% + \expandafter\simplefifoloop\expandafter{\remove@tempa}% + \undefcs\remove@tempa + \popfunctions\if@checklp\cpt@depth +} +\robust@def*\cptdeclarefilter#1{% + \edef\cpt@usefilter##1##2{% + \ifblankTF{#1}{\let##2##1}{% + \ifxTF{#1}\relax{\let##2##1}{\unexpanded{#1}{##1}{##2}}% + }% + }% +} +\robust@def*\cptfiltermergelists{\cpt@testopt\cpt@filtermergelists{,}} +\robust@def*\cpt@filtermergelists[#1]#2#3#4{% + \begingroup + \cptdeclarefilter{#4}% + \ifdefTF{#2}{% + \ifcsnullTF#2{}{\cpt@sttrue\cpt@csvnormalize[#1]#2}% + }{% + \def#2{}% + }% + \ifblankTF{#3}{% + \def\cpt@update{}% + }{% + \edef\cpt@update{\unexpanded{#3}}% + \cpt@sttrue\cpt@csvnormalize[#1]\cpt@update + }% + \def\cpt@add##1{% + \edef#2{\ifx#2\@empty\else\expandcsonce#2#1\fi + \expandcsonce{##1}}% + }% + \def\fifo@do##1{% + \@choicefdfalse + \edef\cpt@merge@a{\unexpanded{##1}}% + \cpt@usefilter\cpt@merge@a\cpt@merge@b + \def\fifo@do####1{% + \edef\cpt@merge@c{\unexpanded{####1}}% + \cpt@usefilter\cpt@merge@c\cpt@merge@d + \cptscantokens\cpt@merge@b + \cptscantokens\cpt@merge@d + \ifx\cpt@merge@b\cpt@merge@d + \@choicefdtrue\cpt@add\cpt@merge@a + \else + \cpt@add\cpt@merge@c + \fi + }% + \cptexpandargonce{\def#2{}\cpt@stfalse\cpt@xDfifo[#1]}#2% + \if@boolTF{@choicefd}{}{\cpt@add\cpt@merge@a}% + }% + \ifcsnullTF#2{% + \edef#2{\expandcsonce\cpt@update}% + }{% + \ifcsnullTF\cpt@update{}{% + \cpt@sttrue\cpt@xDfifo[#1]\cpt@update + }% + }% + \exitgroupdef#2% +} +\robust@def*\cptfilterremoveelements{% + \cpt@testopt\cpt@filterremoveelements{,}% +} +\robust@def*\cpt@filterremoveelements[#1]#2#3#4{% + \begingroup + \cptdeclarefilter{#4}% + \ifdefTF{#2}{}{\def#2{}}% + \ifcsnullTF#2{}{\cpt@sttrue\cpt@csvnormalize[#1]#2}% + \edef\cpt@delete{\unexpanded{#3}}% + \ifcsnullTF\cpt@delete + {}{\cpt@sttrue\cpt@csvnormalize[#1]\cpt@delete}% + \edef\cpt@tempd##1{% + {\detokenize{#1}\noexpand\cptoxdetok{##1}\detokenize{#1}}% + {\detokenize{#1}\cptoxdetok\cpt@delete\detokenize{#1}}% + }% + \def\cpt@tempc{}% + \def\fifo@do##1{% + \edef\cpt@tempa{\unexpanded{##1}}% + \cpt@usefilter\cpt@tempa\cpt@tempb + \expandafter\xifinsetTF\cpt@tempd\cpt@tempb{}{% + \cpt@stfalse\cpt@addtolist[#1]\cpt@tempc{##1}% + }% + }% + \ifcsnullTF#2{}{% + \ifcsnullTF\cpt@delete{}{\cpt@sttrue\cpt@oneDfifo[#1]#2}% + }% + \let#2\cpt@tempc + \exitgroupdef#2% } \robust@def*\preservebracedefQ#1#2{% \def\preserve@prefix{#1}% @@ -1224,58 +1494,81 @@ }% } \robust@def*\cptglet{\global\let} -\robust@def*\csn@def#1{\cptthreexp\def\@nameuse{#1}} -\robust@def*\csn@gdef#1{\cptthreexp\gdef\@nameuse{#1}} -\robust@def*\csn@edef#1{\cptthreexp\edef\@nameuse{#1}} -\robust@def*\csn@xdef#1{\cptthreexp\xdef\@nameuse{#1}} -\robust@def*\csn@let@cs#1{\cptthreexp\let\@nameuse{#1}} -\robust@def*\cs@let@csn#1#2{% +\@namedef{@gobblespace} {} +\robust@def*\csn@def#1{\cptthreexp\def\usecsn{#1}} +\robust@def*\csn@gdef#1{\cptthreexp\gdef\usecsn{#1}} +\robust@def*\csn@edef#1{\cptthreexp\edef\usecsn{#1}} +\robust@def*\csn@xdef#1{\cptthreexp\xdef\usecsn{#1}} +\robust@def*\letcsntocs#1{\cptthreexp\let\usecsn{#1}} +\robust@def*\gletcsntocs#1{\global\cptthreexp\let\usecsn{#1}} +\robust@def*\letcstocsn#1#2{% \begingroup\expandafter\endgroup\expandafter \let\expandafter#1\csname#2\endcsname } -\robust@def*\csn@let@csn#1#2{% +\robust@def*\gletcstocsn#1#2{% + \begingroup\expandafter\endgroup\expandafter\global + \expandafter\let\expandafter#1\csname#2\endcsname +} +\robust@def*\letcsntocsn#1#2{% \begingroup\expandafter\endgroup \expandafter\let\csname#1\expandafter \endcsname\csname#2\endcsname } -\new@def\cptaftercs#1#2{% +\robust@def*\gletcsntocsn#1#2{% + \begingroup\expandafter\endgroup\expandafter + \global\expandafter\let\csname#1\expandafter + \endcsname\csname#2\endcsname +} +\new@def\aftercsname#1#2{% \expandafter\cptswap\expandafter{\csname#2\endcsname}{#1}% } -\new@def\cptuse#1{\ifcsndefTF{#1}{\@nameuse{#1}}{}} -\robust@def*\cptglobalize#1{\cptglet#1#1} -\robust@def*\undef@cs#1{\let#1\@undefined} -\robust@def*\undef@csn#1{\cptthreexp\undef@cs\@nameuse{#1}} -\robust@def*\undef@csset{\cpt@testst\cpt@undefcsset} +\new@def\xaftercsname#1#2{% + \cptsevenxp\cptswap\cptthreexp{\csname#2\endcsname}{#1}% +} +\robust@def*\globalize#1{\cptglet#1#1} +\robust@def*\globalizecsn#1{% + \begingroup\expandafter\endgroup\expandafter + \global\expandafter\let\csname#1\expandafter\endcsname + \csname#1\endcsname +} +\robust@def*\undefcs#1{\let#1\cpt@undefined} +\robust@def*\gundefcs{\global\undefcs} +\robust@def*\undefcsn#1{\aftercsname\undefcs{#1}} +\robust@def*\gundefcsn{\global\undefcsn} +\robust@def*\undefcsset{\cpt@testst\cpt@undefcsset} \robust@def*\cpt@undefcsset#1{% \ifcpt@st\let\cpt@tempa#1\else\def\cpt@tempa{#1}\fi \normaloneDloop*\cpt@tempa\cpt@tempa{% - \expandafter\ifcptescapedTF\cpt@tempa{% - \expandafter\undef@cs\cpt@tempa + \expandafter\ifescapedTF\expandafter{\cpt@tempa}{% + \expandafter\undefcs\cpt@tempa }{% \cpt@err{I can't find escape in token - '\cptxpdetok\cpt@tempa'}\@ehc + '\cptoxdetok\cpt@tempa':\MsgBrk + Maybe it's an active character}\@ehc }% }% } \robust@def*\cpttrimparser{\cpt@testopt\cpt@trimparser{,}} \robust@def\cpt@trimparser[#1]#2{% \begingroup + \edef\cpt@tempd{\detokenize{#1}}% + \let\trimparser@nil\cpt@nil \def\cpt@trimb{% - \xifinsetT{#1\cpt@nil}{\cptxpdetok{#2}\cpt@nil}{% - \def\cpt@trimc####1#1\cpt@nil{% + \xifinsetFT{\cpt@tempd\trimparser@nil}{\cptoxdetok{#2}\trimparser@nil}{}{% + \cptexpandsecond{\def\cpt@trimc####1}\cpt@tempd\trimparser@nil{% \edef#2{\expandcsonce{\@gobble####1}}% \cpt@trimb }% - \expandafter\cpt@trimc\expandafter.#2\cpt@nil + \expandafter\cpt@trimc\expandafter.#2\trimparser@nil }% }% \defpass\cpt@trima{% - \xifinsetTF{\cpt@nil#1}{\cpt@nil\cptxpdetok{#2}}{% - \def\cpt@trimc#1####1\cpt@nil{% + \xifinsetTF{\trimparser@nil\cpt@tempd}{\trimparser@nil\cptoxdetok{#2}}{% + \expandafter\def\expandafter\cpt@trimc\cpt@tempd####1\trimparser@nil{% \edef#2{\unexpanded{####1}}% \cpt@trima }% - \expandafter\cpt@trimc#2\cpt@nil + \expandafter\cpt@trimc#2\trimparser@nil }{% \cpt@trimb }% @@ -1314,9 +1607,12 @@ \unexpanded\cptthreexp{\cpt@stripallouterbraces{#1}}% }% } +\robust@def\stripallouterbraces@incs#1{% + \expandafter\stripallouterbraces\expandafter{#1}#1% +} \robust@def\cpt@stripallouterbraces#1{% \cpt@rnm\ifbracedTF{#1}{% - \expandafter\ifstremptyTF\expandafter{\@secondoftwo#1{}}{% + \expandafter\ifnullTF\expandafter{\@secondoftwo#1{}}{% \expandafter\@gobble\cpt@stripallouterbraces#1% }{0 #1}% }{0 #1}% @@ -1332,38 +1628,46 @@ \ifxTF#2\cpt@tempa {\endgroup\@firstoftwo}{\endgroup\@secondoftwo}% } -\robust@def*\cpt@bracearg{\cpt@testopt\cpt@br@cearg\@ne} -\robust@def\cpt@br@cearg[#1]#2#3{% - \ifbracedTF{#2}{% - \begingroup - \let\nr\z@ - \loop - \edef#3{\unexpanded{{#2}}}% - \pushnumber\nr - \ifnum\nr<#1\relax - \repeat - \exitgroupdef#3% - }{% - \edef#3{\unexpanded{#2}}% - }% -} -\begingroup -\catcode`\&=3 -\new@gdef\xp@despace#1{\cpt@rnm-`\q\cpt@normaldespace.#1& &} -\robust@gdef\normal@despace#1#2{% - \edef#2{\expandcsonce{\cpt@rnm-`\q\cpt@normaldespace.#1& &}}% +\robust@def*\cptbracearg{\cpt@testopt\cpt@bracearg\@ne} +\robust@def\cpt@bracearg[#1]#2#3{% + \begingroup + \let\nr\z@ + \loop + \edef#3{\unexpanded{{#2}}}% + \pushnumber\nr + \ifnum\nr<#1\relax + \repeat + \exitgroupdef#3% } -\robust@gdef\cpt@normaldespace#1 &{\cpt@norm@ldespace#1&} -\robust@gdef\cpt@norm@ldespace#1{\@xp\noexpand\@gobble#1} -\endgroup +\defpass\cpt@tempa#1{% + \new@def\xp@despace##1{% + \cpt@rnm-`\q\cpt@normaldespace.##1\despace@nil#1\despace@nil + }% + \robust@def\normal@despace##1##2{% + \edef##2{% + \unexpanded\expandafter + {\cpt@rnm-`\q\cpt@normaldespace.##1\despace@nil#1\despace@nil}% + }% + }% + \robust@def\cpt@normaldespace##1#1\despace@nil{% + \cpt@norm@ldespace##1\despace@nil + }% + \robust@def\cpt@norm@ldespace##1\despace@nil##2{% + \expandafter\noexpand\@gobble##1% + }% +}{ } \robust@def\robust@despace#1#2{% \edef#2{\unexpanded{#1}}% \let\despace@tempa#2% \normal@despace{#1}#2% - \ifxF#2\despace@tempa{% + \ifxTF#2\despace@tempa{}{% \expandafter\robust@despace\expandafter{#2}#2% }% } +\new@def*\despacecs{\cpt@testpm\cpt@despacecs} +\new@def*\cpt@despacecs#1{% + \usecsn{\ifcpt@pm robust\else normal\fi @despacecontent}{#1}% +} \robust@def*\normal@despacecontent#1{% \expandafter\normal@despace\expandafter{#1}#1% } @@ -1388,128 +1692,136 @@ \do{##1}\cpt@rsvda \cpt@sttrue\cpt@addtolist[#1]\cpt@rsvdb\cpt@rsvda }% - \oneDfifo*[#1]{#2}% + \cpt@sttrue\cpt@oneDfifo[#1]{#2}% \let#2\cpt@rsvdb \exitgroupdef#2% + \undefcs\despace@type } \new@edef*\ifcptmacroTF#1{% \unexpanded{\expandafter\cpt@ifmacro\meaning}% #1\detokenize{macro}:\cpt@nil } +\new@def*\ifcptmacroFT#1{\ifcptmacroTF{#1}\@secondoftwo\@firstoftwo} \edef\cpt@ifmacro{% \def\noexpand\cpt@ifmacro##1\detokenize{macro}:##2\cpt@nil } -\cpt@ifmacro{\@nameuse{@\ifblankTF{#2}{second}{first}oftwo}} -\robust@def*\ifcptescapedTF#1{% - \begingroup\escapechar\cpt@xciipt +\cpt@ifmacro{\usecsn{@\ifblankTF{#2}{second}{first}oftwo}} +\robust@def*\ifescapedTF#1{% + \begingroup\escapechar92\relax \edef\cpt@tempa{\expandafter\cpt@car\string#1x\car@nil}% - \cptthreexp\endgroup\@nameuse{@\ifx\cpt@tempa + \cptthreexp\endgroup\usecsn{@\ifx\cpt@tempa \@backslashchar first\else second\fi oftwo}% } -\robust@def*\@left@addto@macro{% - \let\cpt@def\edef\let\swap\cptswap - \cpt@addtomacro +\robust@def*\ifescapedFT#1{\ifescapedTF{#1}\@secondoftwo\@firstoftwo} +\newcommand*\simplerobustify[1]{% + \def\fifo@do##1{% + \ifescapedTF{##1}{% + \ifdefTF##1{% + \aftercsname\newletcs{rcv@\cptgobblescape##1}##1% + \protected\edef##1{\noexpandcsn{rcv@\cptgobblescape##1}}% + }{% + \cpt@err{Command '\string##1' undefined}\@ehc + }% + }{% + \cpt@err{String '\detokenize{##1}' not escaped}\@ehc + }% + }% + \simplefifoloop{#1}% +} +\robust@def*\leftaddtocs{% + \let\cpt@def\edef\let\swap\cptswap\cpt@addtocs } -\robust@def*\@right@addto@macro{% - \let\cpt@def\edef\let\swap\@alloftwo - \cpt@addtomacro +\robust@def*\gleftaddtocs{% + \let\cpt@def\xdef\let\swap\cptswap\cpt@addtocs } -\robust@def*\g@left@addto@macro{% - \let\cpt@def\xdef\let\swap\cptswap - \cpt@addtomacro +\robust@def*\rightaddtocs{% + \let\cpt@def\edef\let\swap\cptalloftwo\cpt@addtocs } -\robust@def*\g@right@addto@macro{% - \let\cpt@def\xdef\let\swap\@alloftwo - \cpt@addtomacro +\robust@def*\grightaddtocs{% + \let\cpt@def\xdef\let\swap\cptalloftwo\cpt@addtocs } -\robust@def\cpt@addtomacro#1#2{% +\robust@def*\rightaddtocsn{\aftercsname\rightaddtocs} +\robust@def*\grightaddtocsn{\aftercsname\grightaddtocs} +\robust@def*\leftaddtocsn{\aftercsname\leftaddtocs} +\robust@def*\gleftaddtocsn{\aftercsname\gleftaddtocs} +\robust@def\cpt@addtocs#1#2{% + \cpt@getmacroprefix{#1}% \ifdefTF#1{% - \cpt@def#1{\swap{\expandcsonce{#1}}{\unexpanded{#2}}}% + \macroprefix\cpt@def#1{\swap{\expandcsonce{#1}}{\unexpanded{#2}}}% + }{% + \macroprefix\cpt@def#1{\unexpanded{#2}}% + }% + \undefcs\cpt@def\undefcs\swap +} +\robust@def*\cpt@getmacroprefix#1{% + \begingroup + \edef\cpt@tempa##1{\def##1####1\detokenize{macro}:####2\cpt@unique}% + \cpt@tempa\@ifmacro{% + \def\macroprefix{##1}% + \usecsn{@\ifblankTF{##2}{second}{first}oftwo}% + }% + \edef\cpt@tempb##1{##1\detokenize{macro}:\cpt@unique}% + \cpt@tempb{\expandafter\@ifmacro\meaning#1}{% + \@testtrue }{% - \cpt@def#1{\unexpanded{#2}}% + \@testfalse\def\macroprefix{}% + }% + \cptpassexpanded{% + \endgroup\noexpand\scantokens + {\def\noexpand\macroprefix{\macroprefix}\relax}% }% - \undef@cs\cpt@def\undef@cs\swap } \robust@def*\BeforeStartOfDocument{% - \g@right@addto@macro\cpt@beforestartdoc@hook + \grightaddtocs\cpt@beforestartdoc@hook } -\@onlypreamble\BeforeStartOfDocument \new@def*\cpt@beforestartdoc@hook{} -\g@left@addto@macro\document{% +\gleftaddtocs\document{% \endgroup \let\BeforeStartOfDocument\@firstofone \cpt@beforestartdoc@hook \let\BeforeStartOfDocument\@notprerr - \global\undef@cs\cpt@beforestartdoc@hook + \gundefcs\cpt@beforestartdoc@hook \begingroup } \robust@def*\AfterStartOfDocument{% - \g@right@addto@macro\cpt@afterstartdoc@hook + \grightaddtocs\cpt@afterstartdoc@hook } \new@def*\cpt@afterstartdoc@hook{} -\g@right@addto@macro\document{% +\grightaddtocs\document{% \let\AfterStartOfDocument\@firstofone \cpt@afterstartdoc@hook \let\AfterStartOfDocument\@notprerr - \global\undef@cs\cpt@afterstartdoc@hook + \gundefcs\cpt@afterstartdoc@hook \ignorespaces } -\g@left@addto@macro\@popfilename{% - \@nameuse{% +\gleftaddtocs\@popfilename{% + \usecsn{% @\ifcsname\@currname.\@currext-cpt@h@@k\endcsname iden\else gobble\fi }% - {\@nameuse{\@currname.\@currext-cpt@h@@k}}% - \global\undef@csn{\@currname.\@currext-cpt@h@@k}% + {\usecsn{\@currname.\@currext-cpt@h@@k}}% + \gundefcsn{\@currname.\@currext-cpt@h@@k}% } -\robust@def*\cptaddtolist{\cpt@teststoptb\cpt@addtolist} -\robust@def\cpt@addtolist[#1]#2#3{% - \cpt@checklistparser{#1}\relax - \begingroup - \def\cpt@tempa{\endgroup - \ifdefTF#2{% - \ifcpt@st - \protected@edef#2{\expandcsonce#2\ifcsemptyF#2#1#3}% - \else - \edef#2{\expandcsonce#2\ifcsemptyF#2#1\unexpanded{#3}}% - \fi - }{% - \ifcpt@st - \protected@edef#2{#3}% - \else - \edef#2{\unexpanded{#3}}% - \fi +\def\cptloadpackages#1{% + \ifcsnullTF\@currname{% + \cpt@err{Not in a style or class file}\@ehc + }{% + \def\cpt@loadpackages##1##2##3\cpt@nil{% + \@ifpackageloaded{##1}{}{\RequirePackage[##2]{##1}[##3]}% }% - }% - \ifblankTF{#3}{\if@useempty\cpt@tempa\else\endgroup\fi}% - \cpt@tempa -} -\robust@def*\cptaddtocommalist#1#2{% - \ifdefTF{#1}{% - \xdef#1{% - \ifx#1\@empty\else\expandcsonce{#1},\fi - \expandcsonce{#2}% + \@useemptyfalse + \normalxDloop{#1}\cpt@tempa{% + \expandafter\cpt@loadpackages\cpt@tempa\cpt@nil }% - }{% - \xdef#1{\expandcsonce{#2}}% - }% -} -\def\cptloadpackages#1{% - \def\cpt@loadpackages##1##2##3\cpt@nil{% - \@ifpackageloaded{##1}{}{\RequirePackage[##2]{##1}[##3]}% - }% - \@useemptyfalse - \normalxDloop{#1}\cpt@tempa{% - \expandafter\cpt@loadpackages\cpt@tempa\cpt@nil }% } \robust@def*\AfterEndOfStyleFile{% \begingroup \def\cpt@tempa{\endgroup - \expandafter\g@right@addto@macro + \expandafter\grightaddtocs \csname\@currname.\@currext-cpt@h@@k\endcsname }% - \ifcsemptyTF\@currname\endgroup\cpt@tempa + \ifcsnullTF\@currname\endgroup\cpt@tempa } \edef\cpt@hashchar{\string#} \robust@def*\cpt@pushhash{% @@ -1526,7 +1838,8 @@ \ifblankTF{##2}{% \toks@\expandafter{\the\toks@##1}% }{% - \cptpassexpanded{\toks@{\the\toks@##1\cpt@hashchar\cpt@hashchar}}% + \cptpassexpanded + {\toks@{\the\toks@##1\cpt@hashchar\cpt@hashchar}}% \y##2\cpt@nil }% }% @@ -1534,7 +1847,8 @@ }{% \toks@\expandafter{\detokenize{#1}}% }% - \edef#2{\the\toks@}\exitgroupdef#2% + \edef#2{\the\toks@}% + \exitgroupdef#2% } \robust@def*\cpt@pophash{% \begingroup @@ -1558,9 +1872,10 @@ }{% \toks@\expandafter{\detokenize{#1}}% }% - \edef#2{\the\toks@}\exitgroupdef#2% + \edef#2{\the\toks@}% + \exitgroupdef#2% } -\robust@def*\cpt@everyscantoks{% +\robust@def*\cpteveryscantokens{% \everyeof{\noexpand}% \endlinechar\m@ne \makeatletter @@ -1569,31 +1884,25 @@ \catcode`\{\@ne \catcode`\}\tw@ } -\def\cptscantokens#1{% +\robust@def*\cptscantokens#1{% \begingroup - \edef#1{\def\string#1{\cptxpdetok{#1}}}% - \cpt@everyscantoks + \edef#1{\def\string#1{\cptoxdetok{#1}}}% + \cpteveryscantokens \scantokens\expandafter{#1}\relax \exitgroupdef#1% } -\robust@def*\cpt@preamblecmds{% +\cptonlypreamble{% \cptpushcatcodes,\cptpopcatcodes, \UseNormalCatcodes,\rc@UseNormalCatcodes, \StyleFilePurpose,\StyleFileInfo,\AfterEndOfStyleFile, \StyleFileRCSInfo,\SetStyleFileMessages, \XDeclareOption,\XDeclareCommandOption,\XDeclareBooleanOption, - \XProcessOptions,\XExecuteOptions, + \XDeclareCommandOptions,\XDeclareBooleanOptions, + \XDeclareBiBooleanOptions,\XProcessOptions,\XExecuteOptions, \cpt@processedoptions,\cpt@optionlist,\cpt@splitoption, \cpt@processoptions,\cpt@xprocessoptions,\cpt@pr@cessoptions, - \cpt@pr@c@ssoptions -} -\AtEndOfPackage{\undef@cs\cpt@preamblecmds} -\normaloneDloop*\cpt@preamblecmds\cpt@tempa{% - \expandafter\ifcptonetokenTF\expandafter{\cpt@tempa}{% - \expandafter\@onlypreamble\expandafter{\cpt@tempa}% - }{% - \cpt@err{Illegal multiple elements}\@ehc - }% + \cpt@pr@c@ssoptions,\BeforeStartOfDocument, + \AfterStartOfDocument } \robust@def*\csv@@normalize{\cpt@teststoptb\cpt@csvnormalize} \robust@def\cpt@csvnormalize[#1]#2{% @@ -1606,20 +1915,20 @@ \csv@kv@normalize{#1}{#2}\normalized@kvlist } \robust@def\csv@kv@normalize#1#2#3{% - \ifcptonetokenTF{#1}{}{\cpt@err{Multiple list parser}\@ehc}% \let\if@normst\ifcpt@st + \cpt@checklistparser{#1}\relax \begingroup \expandafter\setup@parser@normalize\string#1% - \if@boolTF{@normst}{% + \if@normst \toks@\expandafter{\expandafter#1#2#1}% - }{% + \else \toks@{#1#2#1}% - }% + \fi \normalize@activeparser \expandafter\normalize@spaceletter\string#1% \expandafter\normalize@letterspace\string#1% \expandafter\normalize@doubleletter\string#1% - \ifnumT\normalize@listtype=\@ne{% + \ifnumFT\normalize@listtype=\@ne{}{% \normalize@activeequal \expandafter\normalize@spaceletter\string=% \expandafter\normalize@letterspace\string=% @@ -1629,17 +1938,17 @@ \edef#3{\the\toks@}% \expandafter\cpttrimparser\expandafter[\string#1]#3% \exitgroupdef#3% - \if@normst\let#2#3\undef@cs#3\fi - \undef@cs\if@normst + \if@normst\let#2#3\undefcs#3\fi + \undefcs\if@normst } \def\setup@parser@normalize#1{% \begingroup - \uccode`\~=`#1% + \uccode`\~\string=`#1% \uppercase{\endgroup \def\normalize@activeparser{% \def\cpt@tempa####1~####2\cpt@nil{% \toks@\expandafter{\the\toks@####1}% - \ifblankF{####2}{\cpt@tempa#1####2\cpt@nil}% + \ifblankTF{####2}{}{\cpt@tempa#1####2\cpt@nil}% }% \toks@\expandafter{\expandafter}% \expandafter\cpt@tempa\the\toks@~\cpt@nil @@ -1647,8 +1956,7 @@ }% } \begingroup -\catcode`\= 12 -\uccode`\~=`\=% +\uccode`\~\string=`\=% \uppercase{\endgroup \def\normalize@activeequal{% \def\cpt@tempa##1~##2\cpt@nil{% @@ -1657,7 +1965,7 @@ }{% \toks@\expandafter{\the\toks@=##1}% }% - \ifblankF{##2}{\cpt@tempa##2\cpt@nil}% + \ifblankTF{##2}{}{\cpt@tempa##2\cpt@nil}% }% \toks@\expandafter{\expandafter}\expandafter \cpt@tempa\the\toks@~\cpt@nil @@ -1702,7 +2010,7 @@ \def\cpt@tempa##1,=##2\cpt@nil{% \ifblankTF{##2}{}{% \cpt@err{There is 'comma' next to 'equal' (,=) in - \MsgBrk your key-val list}\@ehc + \MsgBrk your key-value list}\@ehc }% }% \expandafter\cpt@tempa\the\toks@,=\cpt@nil @@ -1712,7 +2020,7 @@ \normaloneDloop*\@filelist\cpt@tempa{% \filename@parse\cpt@tempa \ifx\filename@ext\@clsextension - \ifcsndefT{opt@\filename@area\filename@base.\filename@ext}{% + \ifcsndefFT{opt@\filename@area\filename@base.\filename@ext}{}{% \xdef\cpt@documentclass{% \filename@area\filename@base.\filename@ext }% @@ -1720,37 +2028,46 @@ \fi \ifx\cpt@documentclass\cpt@undefined\else\@breaklooptrue\fi }% - \ifdefF\cpt@documentclass{% + \ifdefTF\cpt@documentclass{}{% \@latex@info@no@line{'catoptions' package loaded before - \string\documentclass}% - }% -} -\ifx\@filelist\relax\else\ifx\@filelist\@gobble\else - \ifx\@filelist\@empty\else - \cptsevenxp\cpt@getdocumentclass -\fi\fi\fi -\ifx\cpt@documentclass\cpt@undefined - \let\cpt@documentclass\@empty - \let\cpt@classoptionslist\@empty -\else - \ifx\@classoptionslist\relax\else - \ifx\@classoptionslist\@empty\else - \kv@@normalize*\@classoptionslist - \fi\fi - \let\cpt@classoptionslist\@classoptionslist - \expandafter\cptemptify\expandafter\@classoptionslist\expandafter - \normaloneDloop\expandafter{\@classoptionslist}\cpt@tempa{% - \oifinsetF{=}\cpt@tempa{% - \cptaddtocommalist\@classoptionslist\cpt@tempa + \string\documentclass: \MsgBrk no problem}% + }% +} +\cptpassunexpanded{% + \ifx\@filelist\relax + \else + \ifx\@filelist\@gobble + \else + \ifx\@filelist\@empty + \else + \cptsevenxp\cpt@getdocumentclass + \fi + \fi + \fi + \ifxTF\cpt@documentclass\cpt@undefined{% + \let\cpt@documentclass\@empty + \let\cpt@classoptionslist\@empty + }{% + \ifxTF\@classoptionslist\relax{}{% + \ifxTF\@classoptionslist\@empty{}{% + \cpt@sttrue\cpt@kvnormalize[,]\@classoptionslist + }% + }% + \let\cpt@classoptionslist\@classoptionslist + \cptexpandargonce{\emptify\@classoptionslist + \normaloneDloop}\@classoptionslist\cpt@tempa{% + \oifinsetTF{=}\cpt@tempa{}{% + \cptaddtocommalist\@classoptionslist\cpt@tempa + }% }% }% -\fi +} \robust@def*\cpt@testfam#1{% \cpt@ifnextchar<{#1}{#1<{\@currname.\@currext}>}% } \robust@redef\@pass@ptions#1#2#3{% \begingroup - \ifcptonetokenTF{#2}{% + \ifsingletokenTF{#2}{% \ifcptmacroTF{#2}{% \let\@expand\expandcsonce }{% @@ -1759,10 +2076,15 @@ }{% \let\@expand\unexpanded }% - \csn@xdef{opt@#3.#1}{% - \ifcsndefT{opt@#3.#1}{\expandcsnonce{opt@#3.#1},}% - \@expand{#2}% + \ifcsndefTF{opt@#3.#1}{% + \ifblankTF{#2}{}{% + \cptexpandarg{\cptexpandsecond{\cpt@filtermergelists[,]}% + {\cptmakecs{opt@#3.#1}}}{\@expand{#2}}{}% + }% + }{% + \csn@edef{opt@#3.#1}{\@expand{#2}}% }% + \globalizecsn{opt@#3.#1}% \endgroup } \robust@redef*\OptionNotUsed{% @@ -1771,9 +2093,9 @@ \fi } \robust@redef*\@use@ption{% - \xifinsetT{,\cptxpdetok\CurrentOption,}% - {,\cptxpdetok\@unusedoptionlist,}{% - \@xpargox{\cpt@killoneelement[,]}\CurrentOption + \xifinsetFT{,\cptoxdetok\CurrentOption,}% + {,\cptoxdetok\@unusedoptionlist,}{}{% + \cptexpandargonce{\cpt@killoneelement[,]}\CurrentOption \@unusedoptionlist }% \csname ds@\CurrentOption\endcsname @@ -1781,7 +2103,7 @@ \robust@redef*\@fileswith@pti@ns#1[#2]#3[#4]{% \begingroup \edef\fileopts{\unexpanded{#2}}% - \ifcsemptyF\fileopts{\kv@@normalize*\fileopts}% + \ifcsnullTF\fileopts{}{\cpt@sttrue\cpt@kvnormalize[,]\fileopts}% \def\fileswithopts##1##2{% \noexpand\@onefilewithoptions{##1}% [\expandcsonce\fileopts]\unexpanded{[#4]##2}% @@ -1806,17 +2128,17 @@ } \let\@@fileswith@pti@ns\@fileswith@pti@ns \robust@def*\RecoverAtEndOfPackage#1{% - \csn@let@cs{rc@\expandafter\@gobble\string#1}#1% + \letcsntocs{rc@\expandafter\@gobble\string#1}#1% \begingroup \edef\cpt@tempa{% \let\unexpanded{#1}% \noexpandcsn{rc@\expandafter\@gobble\string#1}% }% \edef\cpt@tempb{\expandcsnonce{\@currname.\@currext-h@@k}}% - \xifinsetF{\cptxpdetok\cpt@tempa}{\cptxpdetok\cpt@tempb}{% + \xifinsetTF{\cptoxdetok\cpt@tempa}{\cptoxdetok\cpt@tempb}{}{% \expandafter\AtEndOfPackage\expandafter{\cpt@tempa}% }% - \xifinsetF{\cptxpdetok\cpt@tempa}{\cptxpdetok\RequirePackage}{% + \xifinsetTF{\cptoxdetok\cpt@tempa}{\cptoxdetok\RequirePackage}{}{% \xdef\RequirePackage{% \expandcsonce\cpt@tempa\expandcsonce\RequirePackage }% @@ -1825,12 +2147,12 @@ } \RecoverAtEndOfPackage\cpt@defdefault@ds \robust@def*\cpt@badoptionerr{% - \expandafter\ifcptescapedTF\expandafter{\curropt}{% + \expandafter\ifescapedTF\expandafter{\curropt}{% \cpt@err{Bad option name '\expandcsonce\curropt'}\@ehc }{% - \expandafter\ifcptmacroTF\expandafter{\curropt}{% + \expandafter\ifcptmacroFT\expandafter{\curropt}{}{% \cpt@err{Bad option name '\expandcsonce\curropt'}\@ehc - }{}% + }% }% } \robust@def*\XDeclareOption{% @@ -1840,9 +2162,11 @@ {\cpt@testfam\cpt@declareoption}% } \robust@def*\cpt@declareoption<#1>#2{% - \def\curropt{#2}% + \normal@despace{#1}\currfam + \normal@despace{#2}\curropt \cpt@badoptionerr - \cpt@testopt{\cpt@d@clareoption{#1}{#2}}{}% + \cptexpandarg\cpt@testopt + {\cpt@d@clareoption{\currfam}{\curropt}}{}% } \robust@def\cpt@d@clareoption#1#2[#3]#4{% \cpt@d@cl@reoption{#1}{#2}{#3}% @@ -1857,24 +2181,55 @@ }% \cpt@olddxfalse } - +\robust@def*\XDeclareOptions{% + \let\@fileswith@pti@ns\@badrequireerror + \cpt@ifstar{% + \cpt@err{Command \noexpand\XDeclareOptions has no + star form}\@ehc + }{% + \cpt@testfam\cpt@declareoptions + }% +} +\robust@def*\cpt@declareoptions<#1>#2{% + \cpt@testopt{\cpt@d@clareoptions{#1}{#2}}{}% +} +\robust@def\cpt@d@clareoptions#1#2[#3]#4{% + \edef\curr@fam{\xp@despace{#1}}% + \def\curr@opts{#2}% + \cpt@sttrue\cpt@csvnormalize[,]\curr@opts + \def\fifo@do##1{% + \def\curropt{##1}% + \cpt@badoptionerr + \expandafter\cpt@d@clareoption + \expandafter{\curr@fam}{##1}[#3]{#4}% + }% + \cpt@stfalse\cptexpandargonce{\cpt@xDfifo[,]}\curr@opts + \undefcs\curr@opts\undefcs\curr@fam +} \robust@def*\XDeclareCommandOption{% \let\@fileswith@pti@ns\@badrequireerror \let\cmdoption\@ne \cpt@testfam\cpt@declarecmdoption } +\robust@def*\XDeclareCommandOptions{% + \let\@fileswith@pti@ns\@badrequireerror + \let\cmdoption\@ne + \cpt@testfam\cpt@declarecmdoptions +} \robust@def*\XDeclareBooleanOption{% \let\@fileswith@pti@ns\@badrequireerror \let\cmdoption\z@ \cpt@testfam\cpt@declarecmdoption } \robust@def*\cpt@declarecmdoption<#1>#2{% - \def\curropt{#2}% + \normal@despace{#1}\currfam + \normal@despace{#2}\curropt \cpt@badoptionerr - \cpt@testopt{\cpt@d@clarecmdoption{#1}{#2}}{}% + \cptexpandarg\cpt@testopt + {\cpt@d@clarecmdoption{\currfam}{\curropt}}{}% } \robust@def\cpt@d@clarecmdoption#1#2[#3]{% - \cptfullexpandarg{\cpt@testparenopt{\cpt@d@cl@recmdoption + \cptexpandarg{\cpt@testpnopt{\cpt@d@cl@recmdoption {#1}{#2}{#3}}}{\ifnum\cmdoption=\@ne cmd\fi\@currname @}% } \robust@def\cpt@d@cl@recmdoption#1#2#3(#4)#5{% @@ -1882,21 +2237,109 @@ \ifnum\cmdoption=\@ne \def\cpt@rsvda{\csn@def{#4#2}{####1}}% \else - \@fullxpsec{\@nameuse{newif}}{\noexpandcsn{if#4#2}}% + \cptexpandsecond{\usecsn{newif}}{\noexpandcsn{if#4#2}}% \def\cpt@rsvda{% - \ifinsetF{,####1,}{,true,false,}{% + \ifinsetTF{,####1,}{,true,false,}{}{% \@latex@error{Invalid value for option '#2'}\@ehc }% \cptuse{#4#2####1}% }% \fi \long\def\cpt@rsvdb##1{% - \long\csn@gdef{#1@ds@#2}####1{% - ##1\relax - }% + \long\csn@gdef{#1@ds@#2}####1{##1\relax}% }% \expandafter\cpt@rsvdb\expandafter{\cpt@rsvda#5}% } +\robust@def*\XDeclareBooleanOptions{% + \let\@fileswith@pti@ns\@badrequireerror + \let\cmdoption\z@ + \cpt@testfam\cpt@declarecmdoptions +} +\robust@def*\cpt@declarecmdoptions<#1>#2{% + \cpt@testopt{\cpt@d@clarecmdoptions{#1}{#2}}{}% +} +\robust@def\cpt@d@clarecmdoptions#1#2[#3]{% + \cptexpandarg{\cpt@testpnopt{\cpt@d@cl@recmdoptions + {#1}{#2}{#3}}}{\ifnum\cmdoption=\@ne cmd\fi\@currname @}% +} +\robust@def\cpt@d@cl@recmdoptions#1#2#3(#4)#5{% + \edef\curr@fam{\xp@despace{#1}}% + \def\curr@opts{#2}% + \cpt@sttrue\cpt@csvnormalize[,]\curr@opts + \def\fifo@do##1{% + \def\curropt{##1}% + \cpt@badoptionerr + \expandafter\cpt@d@cl@recmdoption + \expandafter{\curr@fam}{##1}{#3}(#4){#5}% + }% + \cpt@stfalse\cptexpandargonce{\cpt@xDfifo[,]}\curr@opts + \undefcs\curr@opts\undefcs\curr@fam +} +\robust@def*\XDeclareBiBooleanOptions{% + \let\@fileswith@pti@ns\@badrequireerror + \let\cmdoption\z@ + \cpt@testfam\cpt@declarebibooloptions +} +\robust@def*\cpt@declarebibooloptions<#1>#2{% + \begingroup + \@tempcnta\z@ + \def\fifo@do##1{\advance\@tempcnta\@ne}% + \simplefifoloop{#2}% + \ifnum\@tempcnta>\tw@ + \cpt@err{Biboolean options '#2' more than 2}\@ehc + \aftergroup\@gobble + \else + \ifnum\@tempcnta<\tw@ + \cpt@err{Biboolean options '#2' less than 2}\@ehc + \aftergroup\@gobble + \fi + \fi + \endgroup + \cpt@testopt{\cpt@d@clarebibooloptions{#1}{#2}}{}% +} +\robust@def\cpt@d@clarebibooloptions#1#2[#3]{% + \cptexpandarg{\cpt@testpnopt{\cpt@d@cl@rebibooloptions + {#1}{#2}{#3}}}{\@currname @}% +} +\robust@def\cpt@d@cl@rebibooloptions#1#2#3(#4)#5#6{% + \edef\curr@fam{\xp@despace{#1}}% + \def\curr@opts{#2}% + \cpt@sttrue\cpt@csvnormalize[,]\curr@opts + \edef\do@prompted##1##2##3{% + \unexpanded{\cptsevenxp\ifstrcmpTF\cptthreexp}% + {\noexpand\csname#4##1@prompted\noexpand\endcsname}{true}{}{% + \XExecuteOptions<\curr@fam>{##2=##3}% + }% + }% + \begingroup + \def\cpt@tempa##1,##2\cpt@nil{% + \endgroup + \csn@def{#4##1@prompted}{false}% + \csn@def{#4##2@prompted}{false}% + \simpleexpandarg\cpt@d@cl@recmdoption\curr@fam{##1}{#3}(#4){% + #5% + \csn@def{#4##2@prompted}{true}% + \ifboolTF{#4##1}{% + \do@prompted{##1}{##2}{false}% + }{% + \do@prompted{##1}{##2}{true}% + }% + \csn@def{#4##2@prompted}{false}% + }% + \simpleexpandarg\cpt@d@cl@recmdoption\curr@fam{##2}{#3}(#4){% + #6% + \csn@def{#4##1@prompted}{true}% + \ifboolTF{#4##2}{% + \do@prompted{##2}{##1}{false}% + }{% + \do@prompted{##2}{##1}{true}% + }% + \csn@def{#4##1@prompted}{false}% + }% + }% + \expandafter\cpt@tempa\curr@opts\cpt@nil + \undefcs\curr@opts\undefcs\curr@fam +} \robust@def\cpt@d@cl@reoption#1#2#3{% \ifcsndefTF{#1@declaredoptions}{% \xifinsetTF{,\detokenize{#2},}{,\cpt@getdeclaredoptions{#1},}{% @@ -1905,7 +2348,7 @@ }% }{% \cpt@stfalse - \cptfullexpandarg{\cpt@addtolist[,]}% + \cptexpandarg{\cpt@addtolist[,]}% {\noexpandcsn{#1@declaredoptions}}{#2}% }% }{% @@ -1916,8 +2359,8 @@ }% } \new@def*\cpt@getdeclaredoptions#1{% - \ifcsnemptyTF{#1@declaredoptions}{}{% - \detokenize\cptsevenxp{\@nameuse{#1@declaredoptions}}% + \ifcsnnullTF{#1@declaredoptions}{}{% + \detokenize\cptsevenxp{\usecsn{#1@declaredoptions}}% }% } \robust@def*\cpt@defdefault@ds<#1>#2{% @@ -1929,11 +2372,11 @@ \@cls@pkg\@space'\@currname'.}% }% } -\letnewcmd\rc@cpt@defdefault@ds\cpt@defdefault@ds +\newletcs\rc@cpt@defdefault@ds\cpt@defdefault@ds \new@def*\cpt@optionlist#1{% - \ifcsndefT{opt@#1}{\unexpanded\cptsevenxp{\@nameuse{opt@#1}}}% + \ifcsndefFT{opt@#1}{}{\unexpanded\cptsevenxp{\usecsn{opt@#1}}}% } -\letnewcmd\cpt@processedoptions\@empty +\newletcs\cpt@processedoptions\@empty \robust@def*\XProcessOptions{% \let\@fileswith@pti@ns\@badrequireerror \edef\cpt@testname{\@currname.\@currext}% @@ -1945,7 +2388,8 @@ \expandcsonce\cpt@classoptionslist\fi }% \edef\@curroptions{\cpt@optionlist{\@currname.\@currext}}% - \ifcsemptyF\@curroptions{\kv@@normalize*\@curroptions}% + \ifcsnullTF\@curroptions{}% + {\cpt@sttrue\cpt@kvnormalize[,]\@curroptions}% \cpt@ifstar {\cpt@sttrue\cpt@testfam\cpt@processoptions}% {\cpt@stfalse\cpt@testfam\cpt@processoptions}% @@ -1958,14 +2402,14 @@ }% } \robust@def*\cpt@pr@cessoptions#1[#2]{% - \def\currfam{#1}% + \normal@despace{#1}\currfam \def\kv@do##1{% \edef\CurrentOption{\unexpanded{##1}}% - \ifcsemptyF\CurrentOption{% + \ifcsnullTF\CurrentOption{}{% \cpt@splitoption\z@ - \if@boolT{cpt@optf}{% + \if@boolFT{cpt@optf}{}{% \cpt@inpoxtrue - \ifcsndefT{#1@ds@\curropt}{% + \ifcsndefFT{#1@ds@\curropt}{}{% \ifblankTF{#2}{% \cpt@igoptfalse }{% @@ -1980,22 +2424,21 @@ }% }% }% - \ifcsemptyF\cpt@classoptions{% - \cptfullexpandarg - {\kv@@parse*}{\noexpandcsn{#1@declaredoptions}}% + \ifcsnullTF\cpt@classoptions{}{% + \cptexpandarg{\kv@@parse*}{\noexpandcsn{#1@declaredoptions}}% }% \cpt@pr@c@ssoptions{#1}{#2}% } \robust@def*\cpt@xprocessoptions#1[#2]{% - \def\currfam{#1}% + \normal@despace{#1}\currfam \def\kv@do##1{% \edef\CurrentOption{\unexpanded{##1}}% - \ifcsemptyF\CurrentOption{% + \ifcsnullTF\CurrentOption{}{% \cpt@splitoption\@ne - \xifinsetT{,\cptxpdetok\curropt,}% - {,\cpt@getdeclaredoptions{#1},}{% + \xifinsetFT{,\cptoxdetok\curropt,}% + {,\cpt@getdeclaredoptions{#1},}{}{% \cpt@inpoxtrue - \ifcsndefT{#1@ds@\curropt}{% + \ifcsndefFT{#1@ds@\curropt}{}{% \ifblankTF{#2}{% \cpt@igoptfalse }{% @@ -2010,14 +2453,14 @@ }% }% }% - \ifcsemptyF\cpt@classoptions{\kv@@parse*\cpt@classoptions}% + \ifcsnullTF\cpt@classoptions{}{\kv@@parse*\cpt@classoptions}% \cpt@pr@c@ssoptions{#1}{#2}% } \robust@def*\cpt@pr@c@ssoptions#1#2{% - \def\currfam{#1}% + \normal@despace{#1}\currfam \def\kv@do##1{% \edef\CurrentOption{\unexpanded{##1}}% - \ifcsemptyF\CurrentOption{% + \ifcsnullTF\CurrentOption{}{% \cpt@splitoption\@ne \cpt@inpoxtrue \ifcsndefTF{#1@ds@\curropt}{% @@ -2033,21 +2476,21 @@ \cpt@useoption }{% \ifcsndefTF{#1@default@ds}{% - \@nameuse{#1@default@ds}% + \usecsn{#1@default@ds}% }{% \default@ds }% }% }% }% - \ifcsemptyF\@curroptions{\kv@@parse*\@curroptions}% + \ifcsnullTF\@curroptions{}{\kv@@parse*\@curroptions}% \let\CurrentOption\@empty \ifx\cpt@documentclass\cpt@undefined \cptglet\cpt@pr@cessedoptions\cpt@processedoptions \else \let\cpt@pr@cessedoptions\@empty \fi - \undef@cs\cpt@classoptions + \undefcs\cpt@classoptions \let\cpt@processedoptions\@empty \let\@fileswith@pti@ns\@@fileswith@pti@ns \cpt@olddxfalse @@ -2055,17 +2498,17 @@ } \robust@def*\XExecuteOptions{\cpt@testfam\cpt@executeoptions} \robust@def*\cpt@executeoptions<#1>#2{% - \def\currfam{#1}% + \normal@despace{#1}\currfam \let\cpt@executedoptions\@empty \let\rc@CurrentOption\CurrentOption \def\kv@do##1{% \edef\CurrentOption{\unexpanded{##1}}% - \ifcsemptyF\CurrentOption{% + \ifcsnullTF\CurrentOption{}{% \cpt@splitoption\@ne - \xifinsetTF{,\cptxpdetok\curropt,}% + \xifinsetTF{,\cptoxdetok\curropt,}% {,\cpt@getdeclaredoptions{#1},}{% - \xifinsetTF{,\cptxpdetok\curropt,}% - {,\cptxpdetok\cpt@executedoptions,}{% + \xifinsetTF{,\cptoxdetok\curropt,}% + {,\cptoxdetok\cpt@executedoptions,}{% \cpt@warn{Option '\curropt' multiply submitted to \MsgBrk\string\XExecuteOptions: re-executed}% }{% @@ -2087,9 +2530,9 @@ \ifcase#1\relax \cpt@optffalse \oneDloop@b\cpt@classoptions\@currentoption{% - \ifcsemptyF\@currentoption{% - \xifinsetTF{=}{\cptxpdetok\@currentoption}{% - \@xp\cpt@split@ption\@currentoption=\cpt@nil + \ifcsnullTF\@currentoption{}{% + \xifinsetTF{=}{\cptoxdetok\@currentoption}{% + \expandafter\cpt@split@ption\@currentoption=\cpt@nil }{% \let\@curropt\@currentoption \let\@currval\@empty @@ -2104,7 +2547,7 @@ }% \or \let\currentoption\CurrentOption - \xifinsetTF{=}{\cptxpdetok\CurrentOption}{% + \xifinsetTF{=}{\cptoxdetok\CurrentOption}{% \expandafter\cpt@split@ption\CurrentOption=\cpt@nil \let\curropt\@curropt \let\currval\@currval @@ -2131,8 +2574,8 @@ } \robust@def*\cpt@useoption{% \ifcpt@inpox - \xifinsetF{,\cptxpdetok\CurrentOption,}% - {,\cptxpdetok\cpt@processedoptions,}{% + \xifinsetTF{,\cptoxdetok\CurrentOption,}% + {,\cptoxdetok\cpt@processedoptions,}{}{% \cptaddtocommalist\cpt@processedoptions\CurrentOption }% \remove@curr@option\currentoption @@ -2144,8 +2587,8 @@ \ifcpt@olddx \cptuse{\currfam @ds@\curropt}% \else - \ifcsndefT{\currfam @ds@\curropt}{% - \ifcsemptyTF\currval{% + \ifcsndefFT{\currfam @ds@\curropt}{}{% + \ifcsnullTF\currval{% \cptthreexp\cpt@usedefault \csname\currfam @ds@\curropt @default\endcsname\cpt@nil }{% @@ -2157,7 +2600,7 @@ } \robust@def*\cpt@use@ption{% \cpt@pushoptionstate - \@xpargox{\cptuse{\currfam @ds@\curropt}}\currval\relax + \cptexpandargonce{\cptuse{\currfam @ds@\curropt}}\currval\relax \cpt@popoptionstate } \robust@def*\cpt@usedefault#1#2\cpt@nil{% @@ -2185,34 +2628,32 @@ \cpt@popoptionstate }% } -\robust@def*\cpt@optionstate{% - \currfam,\curropt,\currval,\CurrentOption,\currentoption,% - \ifcpt@inpox,\ifcpt@optf,\ifcpt@igopt -} \robust@def*\cpt@pushoptionstate{% - \@xp\pushfunctions\@xp{\cpt@optionstate}\cpt@optdepth + \pushfunctions{\currfam,\curropt,\currval,\CurrentOption,% + \currentoption,\ifcpt@inpox,\ifcpt@optf,\ifcpt@igopt}\cpt@optdepth } \robust@def*\cpt@popoptionstate{% - \@xp\popfunctions\@xp{\cpt@optionstate}\cpt@optdepth + \popfunctions{\currfam,\curropt,\currval,\CurrentOption,% + \currentoption,\ifcpt@inpox,\ifcpt@optf,\ifcpt@igopt}\cpt@optdepth } \robust@def*\remove@curr@option#1{% - \@xpargox{\cpt@killoneelement[,]}{#1}\@unusedoptionlist + \cptexpandargonce{\cpt@killoneelement[,]}{#1}\@unusedoptionlist } \BeforeStartOfDocument{% - \ifdefT\cpt@pr@cessedoptions{% - \ifcsemptyF\cpt@pr@cessedoptions{% - \ifcsemptyF\@unusedoptionlist{% + \ifdefFT\cpt@pr@cessedoptions{}{% + \ifcsnullTF\cpt@pr@cessedoptions{}{% + \ifcsnullTF\@unusedoptionlist{}{% \oneDloop@b\cpt@pr@cessedoptions\cpt@tempa{% - \xifinsetT{,\cptxpdetok\cpt@tempa,}% - {,\cptxpdetok\@unusedoptionlist,}{% + \xifinsetFT{,\cptoxdetok\cpt@tempa,}% + {,\cptoxdetok\@unusedoptionlist,}{}{% \remove@curr@option\cpt@tempa }% }% }% }% }% - \cptglobalize\@unusedoptionlist - \undef@cs\cpt@pr@cessedoptions + \globalize\@unusedoptionlist + \undefcs\cpt@pr@cessedoptions } \cptpassunexpanded{% \begingroup @@ -2245,6 +2686,7 @@ \expandafter\cpt@tempa\else\expandafter\endgroup\fi } \XDeclareBooleanOption{verbose}[true](cpt@){} +\XDeclareBiBooleanOptions{draft,final}[true](mp@){}{} \XDeclareBooleanOption{usepox}[true](cpt@){% \ifcpt@usepox \AtEndOfPackage{% @@ -2260,6 +2702,7 @@ \cptpopcatcodes \cptrestorecatcodes +\declarefutureletset[fl@]{lbracket,star,rquote} \endinput |