diff options
author | Karl Berry <karl@freefriends.org> | 2010-04-30 22:54:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-04-30 22:54:45 +0000 |
commit | 99edb98c9fa6d2c7930c43ad9b653dcb3022b293 (patch) | |
tree | 0fa95ae400ec6f15419a91687d36b26dc2360d79 /Master/texmf-dist/tex/latex/skeyval | |
parent | f7c4598eeea5dffae80140f1bd79066796cddab8 (diff) |
skeyval 0.6 (30apr10)
git-svn-id: svn://tug.org/texlive/trunk@18059 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/skeyval')
-rw-r--r-- | Master/texmf-dist/tex/latex/skeyval/skeyval.sty | 3239 |
1 files changed, 2199 insertions, 1040 deletions
diff --git a/Master/texmf-dist/tex/latex/skeyval/skeyval.sty b/Master/texmf-dist/tex/latex/skeyval/skeyval.sty index 2f8ed0862be..203a412dbc4 100644 --- a/Master/texmf-dist/tex/latex/skeyval/skeyval.sty +++ b/Master/texmf-dist/tex/latex/skeyval/skeyval.sty @@ -1,24 +1,24 @@ -%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% % -% This is file 'skeyval.sty', version 0.5. % -% % -% Please see the package documentation for user guide. % -% % -% This package and accompanying files may be distributed and/or modified under % -% the conditions of the LaTeX Project Public License, either version 1.3 of % -% this license or any later version. The latest version of this license is in % -% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all % -% distributions of LaTeX version 2005/12/01 or later. % -% % -% The LPPL maintenance status of this software is 'author-maintained'. % -% % -% This software is provided 'as it is', without warranty of any kind, either % -% expressed or implied, including, but not limited to, the implied warranties of % -% merchantability and fitness for a particular purpose. % -% % -% Copyright (c) 2010 Ahmed Musa (a.musa@rocketmail.com). % -% % -%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'skeyval.sty', version 0.6. % +% % +% This package and accompanying files may be distributed and/or % +% modified under the conditions of the LaTeX Project Public License, % +% either version 1.3 of this license or any later version. The latest % +% version of this license is in http://www.latex-project.org/lppl.txt % +% and version 1.3 or later is part of all distributions of LaTeX % +% version 2005/12/01 or later. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% Copyright (c) 2010 Ahmed Musa (a.musa@rocketmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \begingroup \catcode064 11% @ @@ -35,372 +35,1240 @@ } \SKV@tempa \catcode035 06% # +\catcode061 12% = \catcode064 11% @ \catcode123 01% { \catcode125 02% } -\def\SKV@ensurecode#1#2{% +\def\SKV@setcode#1#2{% \edef\SKV@restorecodes{% \SKV@restorecodes \catcode#1 \the\catcode#1\relax }% \catcode#1 #2\relax } -\AtEndOfPackage{\SKV@restorecodes} -\SKV@ensurecode{061}{12}% = -\SKV@ensurecode{044}{12}% , -\SKV@ensurecode{058}{12}% : -\SKV@ensurecode{059}{12}% ; -\SKV@ensurecode{010}{12}% ^^J -\SKV@ensurecode{126}{13}% ~ +\AtEndOfPackage{% + \SKV@AfterPackageEnd{% + \SKV@restorecodes + \SKV@Undef?{\SKV@setcode\SKV@restorecodes}% + }% +} +\SKV@setcode{010}{12}% ^^J +\SKV@setcode{036}{03}% $ +\SKV@setcode{038}{03}% & +\SKV@setcode{040}{12}% ( +\SKV@setcode{041}{12}% ) +\SKV@setcode{042}{12}% * +\SKV@setcode{043}{12}% + +\SKV@setcode{044}{12}% , +\SKV@setcode{045}{12}% - +\SKV@setcode{047}{12}% / +\SKV@setcode{058}{12}% : +\SKV@setcode{059}{12}% ; +\SKV@setcode{063}{12}% ? +\SKV@setcode{091}{12}% [ +\SKV@setcode{093}{12}% ] +\SKV@setcode{096}{12}% ` +\SKV@setcode{126}{13}% ~ \def\SKV@rcsid$#1: #2 #3 #4 #5${#4 v#3} \ProvidesPackage{skeyval}% - [\SKV@rcsid $Id: skeyval.sty,v 0.5 2010/02/26 09:00:00 Ahmed Musa $ + [\SKV@rcsid $Id: skeyval.sty,v 0.6 2010/04/20 09:00:00 Ahmed Musa $ Extensions to the xkeyval parser (AM)] \NeedsTeXFormat{LaTeX2e}[1996/12/01] -\@ifpackageloaded{xkeyval}\relax{\RequirePackage{xkeyval}[2008/08/13]} \ifnum0=0% - \ifx\eTeXversion\SKV@undefined 1\else\ifnum\eTeXversion<\tw@ 1\fi\fi + \ifx\eTeXversion\SKV@undefined1\else\ifnum\eTeXversion<\tw@1\fi\fi \else - \@latex@error{eTeX not loaded or old version}{% - This package requires eTeX version 2 or later.}% + \PackageError{skeyval}{eTeX not loaded or old version}% + {This package requires eTeX version 2 or later.}% + \endinput \fi -\@ifdefinable\SKV@ifdefinable\relax +\newtoks\SKV@toks +\newcount\SKV@depth +\def\@nil{\@unexpandable@protect\@nil} +\def\@nnil{\@nil} +\long\def\SKV@car#1#2\@nil{#1} +\long\def\SKV@cdr#1#2\@nil{#2} +\long\def\SKV@carcube#1#2#3#4\@nil{#1#2#3} +\long\def\@firstofthree#1#2#3{#1} +\long\def\@secondofthree#1#2#3{#2} +\long\def\@thirdofthree#1#2#3{#3} +\newcommand*\@threeexpafter{\expandafter\expandafter\expandafter} +\def\SKV@aftercs#1#2{\expandafter#1\csname#2\endcsname} +\def\SKV@xaftercs#1#2{\@threeexpafter#1\csname#2\endcsname} +\SKV@aftercs\let{SKV@1of1}\@firstofone +\SKV@aftercs\let{SKV@1of2}\@firstoftwo +\SKV@aftercs\let{SKV@2of2}\@secondoftwo +\SKV@aftercs\let{SKV@1of3}\@firstofthree +\SKV@aftercs\let{SKV@2of3}\@secondofthree +\SKV@aftercs\let{SKV@3of3}\@thirdofthree +\def\SKV@ifx#1#2{\@nameuse{SKV@\ifx#1#21\else2\fi of2}} +\def\SKV@unifx#1#2{\@nameuse{SKV@\ifx#1#22\else1\fi of2}} +\def\SKV@csifx#1#2{\begingroup\expandafter\endgroup\expandafter + \SKV@ifx\csname#1\endcsname#2} +\def\SKV@uncsifx#1#2{\begingroup\expandafter\endgroup\expandafter + \SKV@unifx\csname#1\endcsname#2} +\def\SKV@ifxcs#1#2{\begingroup\expandafter\endgroup\expandafter + \SKV@ifx\expandafter#1\csname#2\endcsname} +\def\SKV@unifxcs#1#2{\begingroup\expandafter\endgroup\expandafter + \SKV@unifx\expandafter#1\csname#2\endcsname} +\def\SKV@ifdefined#1{\@nameuse{SKV@\ifdefined#11\else2\fi of2}} +\def\SKV@unifdefined#1{\@nameuse{SKV@\ifdefined#12\else1\fi of2}} +\def\SKV@ifcsname#1{\@nameuse{SKV@\ifcsname#1\endcsname1\else2\fi of2}} +\def\SKV@unifcsname#1{\@nameuse{SKV@\ifcsname#1\endcsname2\else1\fi of2}} +\def\SKV@iftest#1#2{\@nameuse{SKV@\@nameuse{#1}#21\else2\fi of2}} +\begingroup +\def\SKV@tempa{% + \def\SKV@nodocerr{% + \PackageError{skeyval}{'skeyval' package loaded before + \string\documentclass}{Load skeyval package after + \string\documentclass.}% + \endinput + }% + \def\SKV@tempb##1\@nil,{}% + \def\SKV@tempa##1,{% + \def\@currname{##1}% + \SKV@ifx\SKV@documentclass\SKV@undefined{% + \SKV@ifx\@currname\@nnil{}{% + \filename@parse\@currname + \SKV@unifx\filename@ext\@clsextension{}{% + \SKV@unifcsname{opt@\filename@area\filename@base.% + \filename@ext}{}{% + \edef\SKV@documentclass{\filename@area% + \filename@base.\filename@ext}% + }% + }% + \SKV@tempa + }% + }{% + \let\SKV@tempa\SKV@tempb\SKV@tempa + }% + }% + \SKV@ifx\@filelist\relax\SKV@nodocerr{% + \SKV@ifx\@filelist\@gobble\SKV@nodocerr{% + \expandafter\SKV@tempa\@filelist,\@nil,% + }% + }% + \SKV@ifx\SKV@documentclass\SKV@undefined\SKV@nodocerr\relax +} +\SKV@tempa\endgroup \def\SKV@ifdefinable#1{% - \edef\reserved@a{\expandafter\@gobble\string#1}% - \ifdefined#1% - \ifx#1\relax - \expandafter\expandafter\expandafter\@firstofone - \else - \expandafter\expandafter\expandafter\@notdefinable - \fi - \else - \edef\reserved@b{\expandafter\@carcube\reserved@a xxx\@nil}% - \ifx\reserved@b\@qend - \expandafter\expandafter\expandafter\@notdefinable - \else - \ifx\reserved@a\@qrelax - \expandafter\expandafter\expandafter\expandafter - \expandafter\expandafter\expandafter\@notdefinable - \else - \expandafter\expandafter\expandafter\expandafter - \expandafter\expandafter\expandafter\@firstofone - \fi + \begingroup\escapechar92\afterassignment\endgroup + \xdef\reserved@a{\expandafter\@gobble\string#1}% + \SKV@ifdefined#1{% + \SKV@ifx{#1}\relax\@firstofone\@notdefinable + }{% + \edef\reserved@b{\expandafter\SKV@carcube\reserved@a xxx\@nil}% + \SKV@ifx\reserved@b\@qend\@notdefinable + {\SKV@ifx\reserved@a\@qrelax\@notdefinable\@firstofone}% + }% +} +\newcommand*\@ifpackagecurrent[2]{% + \@nameuse{SKV@\SKV@iftest{ifnum}{\@threeexpafter\@parse@version + \csname ver@#1.\@pkgextension\endcsname//00\@nil + <\expandafter\@parse@version#2//00\@nil}{2}{1}of2}} +\newcommand*\@ifpackagenotcurrent[2]{% + \@nameuse{SKV@\@ifpackagecurrent{#1}{#2}{2}{1}of2}} +\@ifpackageloaded{xkeyval}{% + \@ifpackagecurrent{xkeyval}{2008/08/13}{}{% + \PackageError{skeyval}{% + Your loaded version of xkeyval package is not current + }{% + You need version 2.6a (or higher) of xkeyval package. + }% + \endinput + }% +}{\RequirePackage{xkeyval}[2008/08/13]} +\SKV@ifdefinable\SKV@ifdefinable@n\relax +\protected\def\SKV@ifdefinable@n#1{% + \XKV@sp@deflist\SKV@tempa{#1}% + \XKV@for@o\SKV@tempa\SKV@tempa{% + \edef\resvd@a{\@threeexpafter\SKV@car + \expandafter\string\SKV@tempa\@nil}% + \ifx\resvd@a\@backslashchar + \PackageError{skeyval}{Backslash not allowed}{Backslash not + allowed in argument of '\string\SKV@ifdefinable@n'.}% \fi - \fi + \@threeexpafter\SKV@ifdefinable + \expandafter\csname\SKV@tempa\endcsname\relax + }% +} +\SKV@ifdefinable@n{SKV@def,SKV@@def,SKV@pdef,SKV@@pdef, + SKV@gdef,SKV@@gdef,SKV@pgdef,SKV@@pgdef,SKV@edef, + SKV@@edef,SKV@pedef,SKV@@pedef,SKV@redef,SKV@@redef, + SKV@csredef,SKV@predef,SKV@@predef,SKV@cspredef, + SKV@providedef,SKV@@providedef,SKV@providerobustdef, + SKV@@providerobustdef +} +\protected\def\SKV@def{\@star@or@long\SKV@@def} +\def\SKV@@def#1{\SKV@ifdefinable#1{\l@ngrel@x\def#1}} +\protected\def\SKV@gdef{\@star@or@long\SKV@@gdef} +\def\SKV@@gdef#1{\SKV@ifdefinable#1{\l@ngrel@x\gdef#1}} +\protected\def\SKV@edef{\@star@or@long\SKV@@edef} +\def\SKV@@edef#1{\SKV@ifdefinable#1{\l@ngrel@x\edef#1}} +\protected\def\SKV@pdef{\@star@or@long\SKV@@pdef} +\def\SKV@@pdef#1{\SKV@ifdefinable#1{\l@ngrel@x\protected\def#1}} +\protected\def\SKV@pgdef{\@star@or@long\SKV@@pgdef} +\def\SKV@@pgdef#1{\SKV@ifdefinable#1{\l@ngrel@x\protected\gdef#1}} +\protected\def\SKV@pedef{\@star@or@long\SKV@@pedef} +\def\SKV@@pedef#1{\SKV@ifdefinable#1{\l@ngrel@x\protected\edef#1}} +\protected\def\SKV@pxdef{\@star@or@long\SKV@@pxdef} +\def\SKV@@pxdef#1{\SKV@ifdefinable#1{\l@ngrel@x\protected\xdef#1}} +\protected\def\SKV@redef{\@star@or@long\SKV@@redef} +\def\SKV@@redef#1{% + \SKV@ensurescape{#1}% + \SKV@unifdefined{#1}{}{% + \SKV@ifx{#1}\relax{}{% + \SKV@vbsmsg{info}{Command '\string#1' redefined\on@line}% + }% + }% + \l@ngrel@x\def#1% } -\SKV@ifdefinable\SKV@def{\protected\def\SKV@def{\@star@or@long\SKV@aux@def}} -\SKV@ifdefinable\SKV@aux@def{% - \def\SKV@aux@def#1{\SKV@ifdefinable#1{\l@ngrel@x\def#1}}} -\SKV@ifdefinable\SKV@gdef{\protected\def\SKV@gdef{\@star@or@long\SKV@aux@gdef}} -\SKV@ifdefinable\SKV@aux@gdef{% - \def\SKV@aux@gdef#1{\SKV@ifdefinable#1{\global\l@ngrel@x\def#1}}} -\SKV@ifdefinable\SKV@edef{\protected\def\SKV@edef{\@star@or@long\SKV@aux@edef}} -\SKV@ifdefinable\SKV@aux@edef{% - \def\SKV@aux@edef#1{\SKV@ifdefinable#1{\l@ngrel@x\edef#1}}} -\SKV@ifdefinable\SKV@pdef{\protected\def\SKV@pdef{\@star@or@long\SKV@aux@pdef}} -\SKV@ifdefinable\SKV@aux@pdef{% - \def\SKV@aux@pdef#1{\SKV@ifdefinable#1{\protected\l@ngrel@x\def#1}}} -\SKV@ifdefinable\SKV@pedef{\protected\def\SKV@pedef{\@star@or@long\SKV@aux@pedef}} -\SKV@ifdefinable\SKV@aux@pedef{% - \def\SKV@aux@pedef#1{\SKV@ifdefinable#1{\protected\l@ngrel@x\edef#1}}} -\SKV@pdef\SKV@defined@err#1{\def\reserved@a{#1}\@notdefinable} -\SKV@def\SKV@for@ifdefinable#1{% - \SKV@CommandGenParser{,}% - \SKV@for@b#1\SKV@tempa{% - \SKV@expandargs{1}\KV@@sp@def\SKV@tempa\SKV@tempa\SKV@nil - \if\expandafter\expandafter\expandafter\SKV@car\expandafter - \string\SKV@tempa\SKV@nil\@backslashchar - \SKV@err{Backslash not allowed}\@ehc - \fi - \SKV@ifnameundef\SKV@tempa{}{\SKV@defined@err\SKV@tempa}% +\protected\def\SKV@csredef{\SKV@aftercs\SKV@redef} +\protected\def\SKV@predef{\@star@or@long\SKV@@predef} +\def\SKV@@predef#1{% + \SKV@ensurescape{#1}% + \SKV@unifdefined{#1}{}{% + \SKV@ifx{#1}\relax{}{% + \SKV@vbsmsg{info}{Command '\string#1' redefined\on@line}% + }% }% + \l@ngrel@x\protected\def#1% +} +\protected\def\SKV@cspredef{\SKV@aftercs\SKV@predef} +\SKV@def\SKV@vbsmsg#1#2{% + \begingroup + \def\@i{info}\def\@ii{warn}\def\@iii{#1}% + \csname SKV@\ifSKV@verbose1\else2\fi of2\endcsname + {\SKV@ifx\@i\@iii + {\SKV@info{#2}}% + {\SKV@ifx\@ii\@iii{\SKV@warn{#2}}{}}% + }{}% + \endgroup } +\define@boolkeys[KV]{skeyval@i}[SKV@]{st,pl,ask,sk,loc,uv}[true] +\setkeys[KV]{skeyval@i}{st,pl,ask,sk,loc,uv} +\define@boolkey+[KV]{skeyval}[SKV@]{verbose}[true]{}{% + \SKV@inputerr{#1}{verbose}% +} +\setkeys[KV]{skeyval}{verbose=false} \SKV@pdef\SKV@info#1{\PackageInfo{skeyval}{#1\@gobble}} \SKV@pdef\SKV@warn#1{\PackageWarningNoLine{skeyval}{#1}} \SKV@pdef\SKV@err#1#2{\PackageError{skeyval}{#1}{#2}} -\SKV@def*\SKV@nil{\noexpand\SKV@nil} -\SKV@def*\SKV@nnil{\SKV@nil} -\SKV@def\SKV@car#1#2\SKV@nil{#1} -\gdef\@notprerr{\SKV@err{You've issued a preamble command here}% - {Take command to preamble.}} +\SKV@def*\SKV@MB{\MessageBreak} \SKV@pdef\SKV@afterfi#1\fi{\fi#1} \SKV@pdef\SKV@afterelsefi#1\else#2\fi{\fi#1} -\SKV@def\SKV@aftercsname#1#2{\expandafter#1\csname#2\endcsname} -\SKV@def\SKV@findescape#1{% - \begingroup\escapechar92 \expandafter\endgroup - \if\expandafter\SKV@car\string#1\SKV@nil\@backslashchar - \expandafter\@firstoftwo +\SKV@pdef\SKV@afterfifi#1\fi#2\fi{\fi#2\fi#1} +\SKV@def*\SKV@state#1#2#3{% + \ifcase#1\relax + \def\SKV@ste{XKV@prefix,XKV@fams,XKV@tkey,XKV@na,ifXKV@st,% + ifXKV@pl,ifXKV@knf,CurrentOption,ifSKV@sk}% + \SKV@ifempty{#3}{\advance\XKV@depth\@ne}{}% + \or + \def\SKV@ste{ifSKV@st,ifSKV@pl,ifSKV@ask}% + \SKV@ifempty{#3}{\advance\SKV@depth\@ne}{}% \else - \expandafter\@secondoftwo + \SKV@err{Unknown state identifier}% + {I expected '\string#1' to be number 0 or 1.}% + \fi + \XKV@for@o\SKV@ste\SKV@ste{% + \SKV@aftercs\let{\SKV@ste#2\SKV@aftercs}{\SKV@ste#3}% + }% + \ifcase#1\relax + \SKV@ifempty{#2}{\advance\XKV@depth\m@ne}{}% + \or + \SKV@ifempty{#2}{\advance\SKV@depth\m@ne}{}% \fi } -\SKV@def*\SKV@expandox#1{\unexpanded\expandafter{#1}} -\SKV@def*\SKV@expandnameox#1{\SKV@aftercsname\SKV@expandox{#1}} -\SKV@def*\SKV@expandtx#1{\unexpanded\expandafter\expandafter\expandafter{#1}} -\SKV@def*\SKV@expandnametx#1{\SKV@aftercsname\SKV@expandtx{#1}} -\SKV@def*\SKV@noexpandcs#1{\SKV@aftercsname\noexpand{#1}} -\SKV@pdef\SKV@undef#1{\let#1\SKV@undefined} -\SKV@pdef\SKV@gundef#1{\global\let#1\SKV@undefined} -\SKV@pdef\SKV@nameundef#1{\SKV@aftercsname\let{#1}\SKV@undefined} -\SKV@pdef\SKV@namegundef#1{\global\SKV@aftercsname\let{#1}\SKV@undefined} -\SKV@def\SKV@ifdef#1{% - \ifdefined#1% - \expandafter\@firstoftwo +\SKV@def*\XKV@savstate{\SKV@state{0}{@\romannumeral\XKV@depth}{}} +\SKV@def*\XKV@resstate{\SKV@state{0}{}{@\romannumeral\XKV@depth}} +\SKV@def*\SKV@savstate{\SKV@state{1}{@\romannumeral\SKV@depth}{}} +\SKV@def*\SKV@resstate{\SKV@state{1}{}{@\romannumeral\SKV@depth}} +\def\XKV@srstate#1#2{\SKV@state{0}{#1}{#2}} +\def\SKV@scantoks#1#2{% + \begingroup + \edef\SKV@tempa{\endgroup + \unexpanded{% + #1\everyeof{\noexpand}\endlinechar\m@ne + \makeatletter\scantokens + }{#2}% + \catcode`\noexpand\@=\the\catcode`\@\relax + \everyeof{\the\everyeof}% + \noexpand\endlinechar\the\endlinechar\relax + }% + \SKV@tempa +} +\SKV@def\SKV@newcs#1#2{% + \SKV@ifcsname{#2}{% + \SKV@csifx{#2}\relax{}{\def\reserved@a{#2}\@notdefinable}% + }{\SKV@aftercs{#1}{#2}}% +} +\SKV@pdef*\SKV@csdef{\SKV@savstate\SKV@t@st@pta\SKV@@csdef} +\SKV@def*\SKV@@csdef#1{% + \ifSKV@pl + \let\SKV@n@xt\SKV@newcs \else - \expandafter\@secondoftwo + \let\SKV@n@xt\SKV@aftercs \fi + \SKV@resstate\SKV@n@xt\def{#1}% } -\SKV@def\SKV@ifundef#1{% - \ifdefined#1% - \ifx#1\relax - \expandafter\expandafter\expandafter\@firstoftwo - \else - \expandafter\expandafter\expandafter\@secondoftwo - \fi +\SKV@pdef*\SKV@csgdef{\SKV@savstate\SKV@t@st@pta\SKV@@csgdef} +\SKV@def*\SKV@@csgdef#1{% + \ifSKV@pl + \let\SKV@n@xt\SKV@newcs \else - \expandafter\@firstoftwo + \let\SKV@n@xt\SKV@aftercs \fi + \SKV@resstate\SKV@n@xt\gdef{#1}% } -\SKV@def*\SKV@ifnamedef#1{% - \ifcsname#1\endcsname - \expandafter\@firstoftwo +\SKV@pdef*\SKV@csedef{\SKV@savstate\SKV@t@st@pta\SKV@@csedef} +\SKV@def*\SKV@@csedef#1{% + \ifSKV@pl + \let\SKV@n@xt\SKV@newcs \else - \expandafter\@secondoftwo + \let\SKV@n@xt\SKV@aftercs \fi + \SKV@resstate\SKV@n@xt\edef{#1}% } -\SKV@def*\SKV@ifnameundef#1{% - \ifcsname#1\endcsname - \expandafter\ifx\csname#1\endcsname\relax - \expandafter\expandafter\expandafter\@firstoftwo - \else - \expandafter\expandafter\expandafter\@secondoftwo - \fi +\SKV@pdef*\SKV@csxdef{\SKV@savstate\SKV@t@st@pta\SKV@@csxdef} +\SKV@def*\SKV@@csxdef#1{% + \ifSKV@pl + \let\SKV@n@xt\SKV@newcs \else - \expandafter\@firstoftwo + \let\SKV@n@xt\SKV@aftercs \fi + \SKV@resstate\SKV@n@xt\xdef{#1}% } -\SKV@def\SKV@remparser#1#2{% - \def\tok@i{#1}\edef\tok@ii{#1#2}% - \ifx#2\@empty\else - \def\SKV@remove#1##1\SKV@nil{\def\tok@ii{##1}}% - \SKV@r@move\let#2\tok@ii - \fi +\SKV@def*\SKV@csuse#1{\SKV@ifcsname{#1}{\@nameuse{#1}}{}} +\SKV@pdef\SKV@expargs#1#2#3#4\@nil{% + \begingroup + \protected@edef\SKV@tempa{\endgroup + \ifcase#1\relax + \unexpanded{#2}{#3}% + \or + \unexpanded{#2#3}{#4}% + \or + \unexpanded{#2}{#3}{#4}% + \or + \unexpanded{#2}#3\unexpanded{#4}% + \else + \SKV@err{Unknown expansion type '\string#1' for + \string\SKV@expargs}{I expected your first + argument '\string#1' to be between 0 and 3.}% + \fi + }% + \SKV@tempa } -\SKV@def*\SKV@r@move{\expandafter\SKV@rem@ve\tok@ii\SKV@nil} -\SKV@def*\SKV@rem@ve{\futurelet\@temptoks\SKV@remo@e} -\SKV@def*\SKV@remo@e#1\SKV@nil{% - \if\@temptoks\tok@i - \expandafter\SKV@remove\tok@ii\SKV@nil - \SKV@r@move - \fi +\SKV@def*\SKV@findescape#1{% + \begingroup\escapechar92\relax + \edef\resvd@a{\expandafter\SKV@car\string#1\@nil}% + \expandafter\aftergroup\csname SKV@% + \SKV@ifx\resvd@a\@backslashchar{1}{2}of2\endcsname + \endgroup +} +\SKV@def*\SKV@ensurescape#1{% + \SKV@findescape{#1}{}% + {\SKV@err{Backslash required in '\string#1'}% + {I expected a backslash to be the leading\SKV@MB + character in your argument '\string#1'.}}% } -\SKV@def\SKV@apptomacro@a#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@def*\SKV@ensurenoscape#1{% + \SKV@findescape{#1}% + {\SKV@err{Backslash not allowed in '\string#1'}% + {I didn't expect a backslash to be the leading\SKV@MB + character in your argument '\string#1'.}}{}% +} +\SKV@pdef\SKV@ifnextchar#1#2#3{% + \let\SKV@nxc#1\def\SKV@nxa{#2}\def\SKV@nxb{#3}% + \futurelet\@temptoks\SKV@ifnextch@r +} +\SKV@def*\SKV@ifnextch@r{% + \ifx\@temptoks\SKV@nxc\let\SKV@nxb\SKV@nxa\fi\SKV@nxb +} +\SKV@pdef\SKV@ifstar#1#2{% + \SKV@ifnextchar*{\begingroup + \def\SKV@tempa*{\endgroup #1}\SKV@tempa}{#2}% +} +\SKV@pdef\SKV@ifplus#1#2{% + \SKV@ifnextchar+{\begingroup + \def\SKV@tempa+{\endgroup #1}\SKV@tempa}{#2}% +} +\SKV@pdef\SKV@ifask#1#2{% + \SKV@ifnextchar?{\begingroup + \def\SKV@tempa?{\endgroup #1}\SKV@tempa}{#2}% +} +\SKV@pdef\SKV@ifbrack#1#2{\SKV@ifnextchar[{#1}{#2}} +\SKV@pdef\SKV@ifparen#1#2{\SKV@ifnextchar({#1}{#2}} +\SKV@pdef*\SKV@testopt#1#2{\SKV@ifnextchar[{#1}{#1[{#2}]}} +\SKV@pdef*\SKV@testopta#1{\SKV@t@stopta{\SKV@t@st@pta{#1}}} +\SKV@pdef*\SKV@t@stopta#1{\SKV@ifstar{\SKV@sttrue#1}{\SKV@stfalse#1}} +\SKV@pdef*\SKV@t@st@pta#1{\SKV@ifplus{\SKV@pltrue#1}{\SKV@plfalse#1}} +\SKV@pdef*\SKV@t@st@p@a#1{\SKV@ifask{\SKV@asktrue#1}{\SKV@askfalse#1}} +\SKV@pdef*\SKV@testoptb#1{\SKV@t@stopta{\SKV@t@st@pta{\SKV@t@st@p@a{#1}}}} +\SKV@pdef*\SKV@t@stoptb#1{\SKV@t@stopta{\SKV@t@st@pta{#1}}} +\SKV@pdef*\SKV@testoptc#1{\SKV@t@st@pta{\SKV@t@st@p@a{#1}}} +\SKV@pdef*\SKV@testoptd#1{\SKV@t@stopta{\SKV@testopt#1{,}}} +\SKV@pdef*\SKV@testopte#1{\SKV@testoptb{\SKV@testopt#1{,}}} +\SKV@pdef*\SKV@t@stopte#1{\SKV@t@stoptb{\SKV@testopt#1{,}}} +\SKV@pdef*\SKV@testoptf#1{\SKV@testoptc{\SKV@testopt#1{,}}} +\SKV@def*\SKV@Test@pt#1{\@nameuse{SKV@\SKV@ifempty{#1}{1}{2}of2}} +\SKV@def*\SKV@TestOpt#1#2#3{\SKV@@TestOpt#1&[&{#2#1}{#2[{#3}]{#1}}} +\SKV@def*\SKV@@TestOpt#1[#2#{\SKV@Test@pt{#1#2}} +\SKV@def*\SKV@IfStar#1#2#3{\SKV@@IfStar#1&*&{#2}{#3{#1}}} +\SKV@def*\SKV@@IfStar#1*#2#{\SKV@Test@pt{#1#2}} +\SKV@def*\SKV@IfPlus#1#2#3{\SKV@@IfPlus#1&+&{#2}{#3{#1}}} +\SKV@def*\SKV@@IfPlus#1+#2#{\SKV@Test@pt{#1#2}} +\SKV@def*\SKV@IfAsk#1#2#3{\SKV@@IfAsk#1&?&{#2}{#3{#1}}} +\SKV@def*\SKV@@IfAsk#1?#2#{\SKV@Test@pt{#1#2}} +\SKV@pdef*\NewWrites{\SKV@testopt\SKV@NewWrites{}} +\SKV@pdef*\SKV@NewWrites[#1]#2{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \SKV@aftercs\SKV@ifdefinable{#1\SKV@tempa}{% + \@nameuse{newwrite\SKV@aftercs}{#1\SKV@tempa}% + }% }% - \SKV@ifundef{#1}{% - \edef#1{\unexpanded{#2}}% - }{% - \edef#1{\SKV@expandox#1\unexpanded{#2}}% +} +\SKV@pdef*\NewIfs{\SKV@testopt\SKV@NewIfs{}} +\SKV@pdef*\SKV@NewIfs[#1]#2{\SKV@testopt{\SKV@NewIf@[#1]{#2}}{false}} +\SKV@pdef*\SKV@NewIf@[#1]#2[#3]{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \SKV@aftercs\SKV@ifdefinable{if#1\SKV@tempa}{% + \@nameuse{newif\SKV@aftercs}{if#1\SKV@tempa}% + \@nameuse{#1\SKV@tempa#3}% + }% }% } -\SKV@def\SKV@apptomacro@b#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@pdef*\NewTogs{\SKV@testopt\SKV@NewTogs{}} +\SKV@pdef*\SKV@NewTogs[#1]#2{\SKV@testopt{\SKV@NewT@gs[#1]{#2}}{false}} +\SKV@pdef*\SKV@NewT@gs[#1]#2[#3]{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \edef\SKV@tempa{#1\SKV@tempa}% + \SKV@expnext\newtog\SKV@tempa + \@nameuse{tog#3\SKV@expnext}\SKV@tempa }% - \SKV@ifundef{#1}{% - \edef#1{\SKV@expandox{#2}}% - }{% - \xdef#1{\SKV@expandox#1\SKV@expandox{#2}}% +} +\SKV@pdef*\NewToks{\SKV@testopt\SKV@NewToks{}} +\SKV@pdef*\SKV@NewToks[#1]#2{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \SKV@aftercs\SKV@ifdefinable{#1\SKV@tempa}{% + \@nameuse{newtoks\SKV@aftercs}{#1\SKV@tempa}% + }% }% } -\SKV@def\SKV@preptomacro@a#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@pdef*\NewCounts{\SKV@testopt\SKV@NewCounts{}} +\SKV@pdef*\SKV@NewCounts[#1]#2{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \SKV@aftercs\SKV@ifdefinable{#1\SKV@tempa}{% + \@nameuse{newcount\SKV@aftercs}{#1\SKV@tempa}% + }% }% - \SKV@ifundef{#1}{% - \edef#1{\unexpanded{#2}}% - }{% - \edef#1{\unexpanded{#2}\SKV@expandox#1}% +} +\SKV@pdef*\NewDimens{\SKV@testopt\SKV@NewDimens{}} +\SKV@pdef*\SKV@NewDimens[#1]#2{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \SKV@aftercs\SKV@ifdefinable{#1\SKV@tempa}{% + \@nameuse{newdimen\SKV@aftercs}{#1\SKV@tempa}% + }% }% } -\SKV@def\SKV@preptomacro@b#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@pdef*\NewBoxes{\SKV@testopt\SKV@NewBoxes{}} +\SKV@pdef*\SKV@NewBoxes[#1]#2{% + \SKV@for[,]{#2}\SKV@tempa{% + \SKV@expnext\SKV@ensurenoscape\SKV@tempa + \SKV@aftercs\SKV@ifdefinable{#1\SKV@tempa}{% + \@nameuse{newbox\SKV@aftercs}{#1\SKV@tempa}% + }% }% - \SKV@ifundef{#1}{% - \edef#1{\SKV@expandox{#2}}% +} +\SKV@def\SKV@expnext#1#2{% + \SKV@ifblank{#1}{% + \SKV@err{Arguments of '\string\SKV@expnext' can't be empty}\@ehc }{% - \edef#1{\SKV@expandox{#2}\SKV@expandox#1}% + \SKV@ifblank{#2}{% + \SKV@err{Arguments of '\string\SKV@expnext' can't be empty}\@ehc + }{% + \SKV@iftest{if}{@\detokenize\expandafter{\SKV@cdr#1\@nil}@}{% + \expandafter#1\expandafter{#2}% + }{% + \SKV@err{Invalid arguments '\string#1' for + '\string\SKV@expnext'\SKV@MB}\@ehc + }% + }% }% } -\SKV@def\SKV@gapptomacro@a#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% - }% - \SKV@ifundef{#1}{% - \xdef#1{\unexpanded{#2}}% - }{% - \xdef#1{\SKV@expandox#1\unexpanded{#2}}% +\SKV@pdef*\SKV@DelayedAfterPackageEnd#1{% + \AtEndOfPackage{\SKV@AfterPackageEnd{#1}}} +\SKV@def\DeclarePackageCommand#1#2{% + \SKV@ensurescape{#2}% + \SKV@ifdefined#2{% + \edef\resvd@a{\expandafter\@gobble\string#2}% + \SKV@aftercs\let{Saved\resvd@a}#2% + \edef\resvd@a##1{% + \SKV@DelayedAfterPackageEnd{##1Saved\resvd@a\noexpand\endcsname}% + }% + \resvd@a{\expandafter\let\expandafter#2\csname}% + \let\resvd@a\relax + }{\SKV@DelayedAfterPackageEnd{\SKV@gundef#2}}% + #1#2% +} +\DeclarePackageCommand{\protected\def}\@namegdef{\SKV@aftercs\gdef} +\DeclarePackageCommand{\protected\def}\@nameedef{\SKV@aftercs\edef} +\DeclarePackageCommand{\protected\def}\@namexdef{\SKV@aftercs\xdef} +\SKV@pdef*\SKV@ifnew{\SKV@savstate\SKV@t@stopte\SKV@@ifnew} +\SKV@def*\SKV@@ifnew[#1]#2{% + \ifSKV@st + \ifSKV@pl + \def\SKV@ndl{\SKV@for*[#1]#2}% + \else + \def\SKV@ndl{\SKV@tfor*#2}% + \fi + \else + \ifSKV@pl + \def\SKV@ndl{\SKV@for[#1]{#2}}% + \else + \def\SKV@ndl{\SKV@tfor{#2}}% + \fi + \fi + \SKV@ndl\SKV@ndl{% + \ifSKV@pl + \SKV@despace\SKV@ndl + \SKV@expargs{1}\SKV@aftercs + \SKV@ifdefinable{\SKV@ndl}\@nil\relax + \else + \expandafter\SKV@ifdefinable\SKV@ndl\relax + \fi }% + \SKV@resstate +} +\let\SKV@no\z@ +\SKV@pdef*\SKV@aftergroup{% + \SKV@ifstar{\SKV@aft@rgroup\@firstofone}{\SKV@aft@rgroup\unexpanded}% } -\SKV@def\SKV@gapptomacro@b#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@def\SKV@aft@rgroup#1#2{% + \edef\SKV@no{\the\numexpr\SKV@no+1}% + \SKV@aftercs\xdef{SKV@aft@rgr@up\SKV@no}{% + \SKV@csgundef{SKV@aft@rgr@up\SKV@no}% + #1{#2}% }% - \SKV@ifundef{#1}{% - \xdef#1{\SKV@expandox{#2}}% - }{% - \xdef#1{\SKV@expandox#1\SKV@expandox{#2}}% + \SKV@aftercs\aftergroup{SKV@aft@rgr@up\SKV@no}% +} +\SKV@pdef*\SKV@afterassignment{% + \SKV@ifstar{\SKV@aft@rassignment\@firstofone}% + {\SKV@aft@rassignment\unexpanded}% +} +\SKV@def\SKV@aft@rassignment#1#2{% + \begingroup + \edef\SKV@no{\the\numexpr\SKV@no+1}% + \SKV@aftercs\xdef{SKV@aft@rassignm@nt\SKV@no}{% + \SKV@csgundef{SKV@aft@rassignm@nt\SKV@no}% + #1{#2}% }% + \expandafter\endgroup\expandafter\afterassignment + \csname SKV@aft@rassignm@nt\SKV@no\endcsname } -\SKV@def\SKV@gpreptomacro@a#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@def*\SKV@trailead#1#2{% + \edef\SKV@trail{\the\SKV@toks}% + \SKV@toks\expandafter{\romannumeral-`\q\SKV@tr@ilead\noexpand#1& &}% + \edef#2{\the\SKV@toks}% + \SKV@toks\expandafter{\SKV@trail}% + \SKV@undef\SKV@trail +} +\SKV@def*\SKV@tr@ilead#1 &{\SKV@tr@ile@d#1&} +\SKV@def*\SKV@tr@ile@d#1{\romannumeral-`\q#1} +\SKV@def*\SKV@expox#1{\unexpanded\expandafter{#1}} +\SKV@def*\SKV@expcsox#1{\SKV@aftercs\SKV@expox{#1}} +\SKV@def*\SKV@exptx#1{\unexpanded\@threeexpafter{#1}} +\SKV@def*\SKV@expcstx#1{\SKV@aftercs\SKV@exptx{#1}} +\SKV@pdef*\SKV@undef#1{\let#1\SKV@undefined} +\SKV@pdef\SKV@gundef{\global\SKV@undef} +\SKV@pdef*\SKV@csundef#1{\SKV@aftercs\SKV@undef{#1}} +\SKV@pdef*\SKV@csgundef{\global\SKV@csundef} +\SKV@pdef*\SKV@undeflt#1#2{% + \SKV@ifempty{#1}{\let\glob@lrel@x\relax}{\let\glob@lrel@x\global}% + \SKV@for[,]{#2}\SKV@resvd{% + \SKV@expnext\SKV@ensurescape\SKV@resvd + \glob@lrel@x\expandafter\SKV@undef\SKV@resvd + }% +} +\SKV@pdef*\SKV@Undef{\SKV@savstate\SKV@testopte\SKV@@Undef} +\SKV@def*\SKV@@Undef[#1]#2{% + \ifSKV@st + \ifSKV@pl + \def\SKV@ndl{\SKV@for*[#1]#2}% + \else + \def\SKV@ndl{\SKV@tfor*#2}% + \fi + \else + \ifSKV@pl + \def\SKV@ndl{\SKV@for[#1]{#2}}% + \else + \def\SKV@ndl{\SKV@tfor{#2}}% + \fi + \fi + \SKV@ndl\SKV@ndl{% + \ifSKV@pl + \SKV@despace\SKV@ndl + \ifSKV@ask\expandafter\global\fi + \@threeexpafter\let + \expandafter\csname\SKV@ndl\endcsname\SKV@undefined + \else + \ifSKV@ask\expandafter\global\fi + \expandafter\let\SKV@ndl\SKV@undefined + \fi }% - \SKV@ifundef{#1}{% - \xdef#1{\unexpanded{#2}}% + \SKV@resstate +} +\SKV@def*\SKV@ifdef#1{% + \SKV@ifdefined{#1}% + {\@nameuse{SKV@\SKV@ifx{#1}\relax{2}{1}of2}}\@secondoftwo +} +\SKV@def*\SKV@ifundef#1{\@nameuse{SKV@\SKV@ifdef{#1}{2}{1}of2}} +\SKV@def*\SKV@ifcsdef#1{% + \SKV@ifcsname{#1}% + {\@nameuse{SKV@\expandafter\SKV@ifx\csname#1\endcsname + \relax{2}{1}of2}}\@secondoftwo +} +\SKV@def*\SKV@ifcsundef#1{\@nameuse{SKV@\SKV@ifcsdef{#1}{2}{1}of2}} +\SKV@pdef*\SKV@providedef{\@star@or@long\SKV@@providedef} +\SKV@def\SKV@@providedef#1{% + \edef\SKV@prov@d{\expandafter\@gobble\string#1}% + \SKV@aftercs\let{SKV@test@\SKV@prov@d}\SKV@undefined + \SKV@ifdef#1{% + \SKV@vbsmsg{info}{Command '\string#1' already defined:\SKV@MB + Not redefined\on@line}% + \SKV@afterassignment{\SKV@gundef\SKV@pr@vid}% + \def\SKV@pr@vid }{% - \xdef#1{\unexpanded{#2}\SKV@expandox#1}% + \SKV@afterassignment{% + \SKV@aftercs\edef{SKV@test@\SKV@prov@d}% + {\expandafter\strip@prefix\meaning#1}% + }% + \l@ngrel@x\def#1% }% } -\SKV@def\SKV@gpreptomacro@b#1#2{% - \SKV@findescape{#1}{}{% - \SKV@err{Bad argument '\string#1'}{Backslash required in '\string#1'.}% +\SKV@pdef*\SKV@providerobustdef{\@star@or@long\SKV@@providerobustdef} +\SKV@def\SKV@@providerobustdef#1{% + \edef\SKV@prov@d{\expandafter\@gobble\string#1}% + \SKV@aftercs\let{SKV@test@\SKV@prov@d}\SKV@undefined + \SKV@ifdef#1{% + \SKV@vbsmsg{info}{Command '\string#1' already defined:\SKV@MB + Not redefined\on@line}% + \SKV@afterassignment{\SKV@gundef\SKV@pr@vid}% + \def\SKV@pr@vid + }{% + \SKV@afterassignment{% + \SKV@aftercs\edef{SKV@test@\SKV@prov@d}% + {\expandafter\strip@prefix\meaning#1}% + }% + \l@ngrel@x\protected\def#1% }% +} +\SKV@def\TestProvidedCommand#1{% + \begingroup + \SKV@ifmacro#1{% + \edef\SKV@resvd@a{\expandafter\@gobble\string#1}% + \edef\SKV@resvd@b{\expandafter\strip@prefix\meaning#1}% + \expandafter\aftergroup\csname SKV@\expandafter + \ifx\expandafter\SKV@resvd@b + \csname SKV@test@\SKV@resvd@a\endcsname + 1\else2\fi of2\endcsname + }{\aftergroup\@secondoftwo}% + \endgroup +} +\SKV@pdef*\SKV@newdef{\SKV@def} +\SKV@providerobustdef*\newdef{\SKV@def} +\SKV@pdef*\SKV@robustdef{\SKV@pdef} +\SKV@providerobustdef*\robustdef{\SKV@pdef} +\SKV@providerobustdef*\providedef{\SKV@providedef} +\SKV@providerobustdef*\providerobustdef{\SKV@providerobustdef} +\SKV@def\SKV@ifmacro#1{% + \begingroup + \edef\SKV@ifmacro##1{\def##1####1\detokenize{macro}:####2&}% + \SKV@ifmacro\@ifmacro{\expandafter\aftergroup + \csname SKV@\SKV@ifblank{##2}{2}{1}of2\endcsname}% + \edef\SKV@ifmacro##1{##1\detokenize{macro}:&}% + \SKV@ifmacro{\expandafter\@ifmacro\meaning#1}% + \endgroup +} +\SKV@def\SKV@ifnotmacro#1{\SKV@ifmacro{#1}\@secondoftwo\@firstoftwo} +\SKV@def\SKV@ifparamacro#1{% + \begingroup + \edef\SKV@ifparamacro##1{% + \def##1####1\detokenize{macro}:####2->####3&}% + \SKV@ifparamacro\@ifparam{\expandafter\aftergroup + \csname SKV@\SKV@ifblank{##2}{2}{1}of2\endcsname}% + \edef\SKV@ifparamacro##1{##1\detokenize{macro}:->&}% + \SKV@ifparamacro{\expandafter\@ifparam\meaning#1}% + \endgroup +} +\SKV@def*\SKV@ifrelax#1{% + \SKV@ensurescape{#1}% + \SKV@ifdefined{#1}% + {\@nameuse{SKV@\SKV@ifx{#1}\relax{1}{2}of2}}\@secondoftwo +} +\SKV@def*\SKV@ifcsrelax#1{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsname{#1}% + {\@nameuse{SKV@\expandafter\SKV@ifx\csname#1\endcsname + \relax{1}{2}of2}}\@secondoftwo +} +\SKV@def*\SKV@ifdefax#1{% + \SKV@ensurescape{#1}% + \SKV@ifdefined{#1}% + {\@nameuse{SKV@\SKV@ifx{#1}\relax{2}{1}of3}}\@thirdofthree +} +\SKV@def*\SKV@ifcsdefax#1{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsname{#1}% + {\@nameuse{SKV@\expandafter\SKV@ifx\csname#1\endcsname + \relax{2}{1}of3}}\@thirdofthree +} +\SKV@def*\SKV@despace#1{% + \SKV@ensurescape{#1}% + \SKV@expnext\SKV@trailead{#1}#1% +} +\SKV@def\SKV@detokdespace#1#2{\edef#2{\detokenize{#1}}\SKV@despace#2} +\SKV@def\SKV@ifblank#1{\SKV@ifbl@nk#1&&\@secondoftwo\@firstoftwo:} +\SKV@def\SKV@ifbl@nk#1#2#4#5:{#4} +\SKV@def\SKV@ifnotblank#1{\SKV@ifbl@nk#1&&\@firstoftwo\@secondoftwo:} +\SKV@def\SKV@oifblank#1{\expandafter\SKV@ifblank\expandafter{#1}} +\SKV@def\SKV@xifblank#1{\SKV@expargs{0}\SKV@ifblank{#1}\@nil} +\SKV@def\SKV@ifstrequal#1#2{% + \begingroup + \SKV@detokdespace{#1}\resvd@a\SKV@detokdespace{#2}\resvd@b + \expandafter\aftergroup + \csname SKV@\SKV@ifx\resvd@a\resvd@b{1}{2}of2\endcsname + \endgroup +} +\SKV@def\SKV@ifstrnotequal#1#2{\SKV@ifstrequal{#1}{#2}\@secondoftwo\@firstoftwo} +\SKV@def\SKV@oifstrequal#1#2{% + \@expandtwoargs\SKV@ifstrequal{\SKV@expox{#1}}{\SKV@expox{#2}}} +\SKV@def\SKV@xifstrequal#1#2{\@expandtwoargs\SKV@ifstrequal{#1}{#2}} +\SKV@def\SKV@ifempty#1{\@nameuse{SKV@\ifcat$\detokenize{#1}$1\else2\fi of2}} +\SKV@def\SKV@ifnotempty#1{\@nameuse{SKV@\SKV@ifempty{#1}{2}{1}of2}} +\SKV@def\SKV@oifempty#1{\SKV@expnext\SKV@ifempty{#1}} +\SKV@def\SKV@xifempty#1{\SKV@expargs{0}\SKV@ifempty{#1}\@nil} +\SKV@def*\SKV@remparser{\SKV@testopt\SKV@remp@rser{,}} +\SKV@def\SKV@remp@rser[#1]#2{% + \begingroup + \ifx#2\@empty\else + \edef#2{#1\SKV@expox{#2}}% + \def\SKV@tempa#1##1\@nil{% + \gdef#2{##1}\futurelet\@temptoks\SKV@t@mp##1\@nil + }% + \def\SKV@t@mp##1\@nil{% + \ifx\@temptoks\@sptoken + \SKV@expnext\SKV@trailead{#2}#2% + \expandafter\SKV@tempa\expandafter#1#2\@nil + \else + \if#1\@temptoks\expandafter\SKV@tempa#2\@nil\fi + \fi + }% + \expandafter\SKV@tempa#2\@nil + \fi + \endgroup +} +\SKV@pdef*\SKV@appto{\SKV@savstate\SKV@testoptb\SKV@@appto} +\SKV@def\SKV@@appto#1#2{% + \ifSKV@st + \let\@unexp@expox\SKV@expox + \else + \let\@unexp@expox\unexpanded + \fi + \SKV@ap@to{#1}{#2}% + \SKV@resstate +} +\SKV@def*\SKV@ap@to#1#2{% + \ifSKV@pl + \ifSKV@ask + \let\SKV@n@xt\SKV@csxdef + \else + \let\SKV@n@xt\SKV@csedef + \fi + \SKV@ifcsundef{#1}{% + \SKV@n@xt{#1}{\@unexp@expox{#2}}% + }{% + \SKV@n@xt{#1}{\SKV@expcsox{#1}\@unexp@expox{#2}}% + }% + \else + \ifSKV@ask + \let\SKV@n@xt\xdef + \else + \let\SKV@n@xt\edef + \fi + \SKV@ifundef{#1}{% + \SKV@n@xt#1{\@unexp@expox{#2}}% + }{% + \SKV@n@xt#1{\SKV@expox{#1}\@unexp@expox{#2}}% + }% + \fi +} +\SKV@pdef*\SKV@prepto{\SKV@savstate\SKV@testoptb\SKV@@prepto} +\SKV@def\SKV@@prepto#1#2{% + \ifSKV@st + \let\@unexp@expox\SKV@expox + \else + \let\@unexp@expox\unexpanded + \fi + \SKV@pr@pto{#1}{#2}% + \SKV@resstate +} +\SKV@def*\SKV@pr@pto#1#2{% + \ifSKV@pl + \ifSKV@ask + \let\SKV@n@xt\SKV@csxdef + \else + \let\SKV@n@xt\SKV@csedef + \fi + \SKV@ifcsundef{#1}{% + \SKV@n@xt{#1}{\@unexp@expox{#2}}% + }{% + \SKV@n@xt{#1}{\@unexp@expox{#2}\SKV@expcsox{#1}}% + }% + \else + \ifSKV@ask + \let\SKV@n@xt\xdef + \else + \let\SKV@n@xt\edef + \fi + \SKV@ifundef{#1}{% + \SKV@n@xt#1{\@unexp@expox{#2}}% + }{% + \SKV@n@xt#1{\@unexp@expox{#2}\SKV@expox{#1}}% + }% + \fi +} +\SKV@pdef\apptomac#1#2{% + \SKV@ifundef{#1}{\edef#1{\unexpanded{#2}}}% + {\edef#1{\SKV@expox{#1}\unexpanded{#2}}}% +} +\SKV@pdef*\gapptomac{\global\apptomac} +\SKV@pdef*\csapptomac{\SKV@aftercs\apptomac} +\SKV@pdef*\csgapptomac{\global\csapptomac} +\SKV@pdef\preptomac#1#2{% + \SKV@ifundef{#1}{\edef#1{\unexpanded{#2}}}% + {\edef#1{\unexpanded{#2}\SKV@expox{#1}}}% +} +\SKV@pdef*\gpreptomac{\global\preptomac} +\SKV@pdef*\cspreptomac{\SKV@aftercs\preptomac} +\SKV@pdef*\csgpreptomac{\global\cspreptomac} +\SKV@pdef*\SKV@addtolist{\SKV@savstate\SKV@testoptf\SKV@@addtolist} +\SKV@def*\SKV@@addtolist[#1]{% + \def\parser{#1}% + \ifSKV@pl + \def\SKV@n@xt##1{\SKV@aftercs\SKV@addt@list{##1}}% + \ifSKV@ask + \let\glob@l@or@def\xdef + \else + \let\glob@l@or@def\edef + \fi + \else + \let\SKV@n@xt\SKV@addt@list + \ifSKV@ask + \let\glob@l@or@def\xdef + \else + \let\glob@l@or@def\edef + \fi + \fi + \SKV@resstate\SKV@n@xt +} +\SKV@def\SKV@addt@list#1#2{% \SKV@ifundef{#1}{% - \xdef#1{\SKV@expandox{#2}}% + \glob@l@or@def#1{\SKV@expox{#2}}% }{% - \xdef#1{\SKV@expandox{#2}\SKV@expandox#1}% - }% + \glob@l@or@def#1{\SKV@expox{#1}\parser\SKV@expox{#2}}% + }% +} +\SKV@pdef*\SKV@relax#1{\let#1\relax} +\SKV@pdef*\SKV@grelax{\global\SKV@relax} +\SKV@pdef*\SKV@csrelax{\SKV@aftercs\SKV@relax} +\SKV@pdef*\SKV@csgrelax{\global\SKV@csrelax} +\@ifpackageloaded{atveryend}{% + \@ifpackagecurrent{atveryend}{2010/03/24}{}{% + \SKV@err{Your loaded version of atveryend package is + not current}\@ehc}}{\RequirePackage{atveryend}[2010/03/24]} +\SKV@pdef*\SKV@notprerr{% + \SKV@err{You have issued a preamble command here}% + {Move shown command to document preamble.}% +} +\SKV@pdef*\SKV@notenderr{% + \SKV@err{You've called an \string\enddocument\space command\SKV@MB + at the wrong place}{Move command to before \string\enddocument.}% +} +\SKV@pdef*\SKV@AtDocumentStart{\AtBeginDocument} +\SKV@pdef*\SKV@BeforeDocumentStart{\SKV@appto?\SKV@beforedocstart} +\def\SKV@beforedocstart{} +\SKV@prepto\document{% + \endgroup + \let\SKV@BeforeDocumentStart\@firstofone + \SKV@beforedocstart + \let\SKV@BeforeDocumentStart\SKV@notprerr + \SKV@gundef\SKV@beforedocstart + \begingroup } -\SKV@def*\@afterpackageloaded#1{% - \SKV@ifnamedef{ver@#1.\@pkgextension}{% - \let\SKV@tempa\@firstofone +\SKV@pdef*\SKV@AfterDocumentStart{\SKV@appto?\SKV@afterdocstart} +\def\SKV@afterdocstart{} +\SKV@appto\document{% + \let\SKV@AfterDocumentStart\@firstofone + \SKV@afterdocstart + \let\SKV@AfterDocumentStart\SKV@notprerr + \SKV@gundef\SKV@afterdocstart\ignorespaces +} +\SKV@BeforeDocumentStart{\let\SKV@AtDocumentStart\@firstofone} +\SKV@pdef*\SKV@AtDocumentEnd{\AtEndDocument} +\SKV@pdef*\SKV@BeforeLastPage{\SKV@appto?\SKV@beforelastpage} +\def\SKV@beforelastpage{} +\SKV@AtDocumentEnd{% + \let\SKV@bef@relastpage\AtVeryEnd@BeforeClearDocumentHook + \def\AtVeryEnd@BeforeClearDocumentHook{% + \let\SKV@BeforeLastPage\@firstofone + \SKV@beforelastpage\SKV@bef@relastpage + \let\SKV@BeforeLastPage\SKV@notenderr + \SKV@Undef?{\SKV@beforelastpage\SKV@bef@relastpage}% + }% +} +\SKV@pdef*\SKV@AfterLastPage{\SKV@appto?\SKV@afterlastpage} +\def\SKV@afterlastpage{} +\SKV@AtDocumentEnd{% + \let\SKV@afterl@stpage\AtVeryEnd@AfterLastShipoutHook + \def\AtVeryEnd@AfterLastShipoutHook{% + \let\SKV@AfterLastPage\@firstofone + \SKV@afterlastpage\SKV@afterl@stpage + \let\SKV@AfterLastPage\SKV@notenderr + \SKV@Undef?{\SKV@afterlastpage\SKV@afterl@stpage}% + }% +} +\SKV@pdef*\SKV@AfterDocumentEnd{\SKV@appto?\SKV@afterenddoc} +\def\SKV@afterenddoc{} +\SKV@AtDocumentEnd{% + \let\SKV@aft@renddoc\AtVeryEnd@AtVeryEndDocumentHook + \def\AtVeryEnd@AtVeryEndDocumentHook{% + \let\SKV@AfterDocumentEnd\@firstofone + \SKV@afterenddoc\SKV@aft@renddoc + \let\SKV@AfterDocumentEnd\SKV@notenderr + \SKV@Undef?{\SKV@afterenddoc\SKV@aft@renddoc}% + }% +} +\SKV@pdef\SKV@AtPackageEnd{\AtEndOfPackage} +\SKV@pdef*\SKV@BeforePackageEnd{% + \SKV@prepto+{\@currname.\@currext-h@@k}% +} +\SKV@pdef*\SKV@AfterPackageEnd{% + \SKV@appto+{\@currname.\@currext-skvh@@k}% +} +\let\SKV@AtClassEnd\SKV@AtPackageEnd +\let\SKV@BeforeClassEnd\SKV@BeforePackageEnd +\let\SKV@AfterClassEnd\SKV@AfterPackageEnd +\SKV@prepto\@popfilename{% + \SKV@csuse{\@currname.\@currext-skvh@@k}% + \SKV@csgundef{\@currname.\@currext-skvh@@k}% +} +\SKV@pdef\@afterpackageloaded#1{% + \SKV@AtDocumentStart{% + \SKV@ifcsdef{ver@#1.\@pkgextension}{}{% + \SKV@warn{Package '#1' was never loaded}% + }% + } + \SKV@ifcsdef{ver@#1.\@pkgextension}{% + \let\SKV@n@xt\@firstofone }{% - \def\SKV@tempa{\SKV@aftercsname\SKV@apptomacro@a{#1.\@pkgextension @afpl}}% + \def\SKV@n@xt{\SKV@appto+{#1.\@pkgextension-skvh@@k}}% }% - \SKV@tempa + \SKV@n@xt } -\SKV@preptomacro@a\@popfilename{% - \SKV@nameuse{\@currname.\@currext @afpl}% - \SKV@nameundef{\@currname.\@currext @afpl}% +\let\SKV@steno\z@ +\SKV@pdef*\SKV@for{\SKV@savstate\SKV@testoptd\SKV@@for} +\SKV@pdef*\SKV@@for[#1]{% + \let\SKV@steno\@ne + \ifSKV@st + \def\SKV@n@xt{\SKV@for@b[#1]}% + \else + \def\SKV@n@xt{\SKV@CommandGenParser{#1}\SKV@for@a}% + \fi + \SKV@n@xt } -\@onlypreamble\@afterpackageloaded -\SKV@def\ReserveKeyPrefixNames#1{\SKV@apptomacro@a\SKV@rkpnames{,#1}} -\SKV@def\ReserveMacroPrefixNames#1{\SKV@apptomacro@a\SKV@rmpnames{,#1}} -\SKV@def\ReserveFamilyNames#1{\SKV@apptomacro@a\SKV@rfnames{,#1}} -\SKV@def*\SKV@rkpnames{XKV} -\SKV@def*\SKV@rmpnames{XKV} -\SKV@def*\SKV@rfnames{XKV} \SKV@pdef*\SKV@CommandGenParser#1{% \def\parser{#1}% \protected\long\def\SKV@for@a##1##2##3{% - \edef##2{\unexpanded{##1}}% - \SKV@oifblank{##2}\SKV@fornoop\SKV@forloop - ##2{##3}##1#1\SKV@nil#1% + \SKV@ifblank{##1}\SKV@fornoop\SKV@forloop + ##2{##3}##1#1\@nil }% - \long\def\SKV@forloop##1##2##3#1{% + \long\def\SKV@forloop##1##2##3#1##4\@nil{% \edef##1{\unexpanded{##3}}% - \ifx##1\SKV@nnil - \expandafter\@gobbletwo - \else - ##2\expandafter\SKV@forloop - \fi - ##1{##2}% + \SKV@ifstrequal{##3}{\listbreak}{% + \SKV@keylistrema##4\@nil#1% + }{% + \SKV@ifblank{##4}{% + ##2\relax + \ifnum\SKV@steno=\@ne\expandafter\SKV@resstate\fi + \let\SKV@steno\z@ + }{% + ##2\relax\SKV@forloop##1{##2}##4\@nil + }% + }% }% - \long\def\SKV@fornoop##1\SKV@nil#1{}% + \long\def\SKV@fornoop##1\@nil{}% } -\SKV@pdef\SKV@for@b#1{\expandafter\SKV@for@a\expandafter{#1}} -\SKV@pdef*\SKV@tfor@a#1#2#3{\SKV@ifblank{#2}{}{\@tf@r#1{#2}\do{#3}}} -\SKV@pdef*\SKV@tfor@b#1#2#3{% - \SKV@expandargs{3}{\SKV@tfor@a#1}{{\SKV@expandox{#2}}}{{#3}}\SKV@nil +\SKV@pdef*\SKV@for@b{\SKV@testopt\SKV@@for@b{,}} +\SKV@def\SKV@@for@b[#1]#2{% + \SKV@CommandGenParser{#1}% + \SKV@expnext\SKV@for@a{#2}% } -\SKV@def\SKV@checksanitizec#1#2{% - \XKV@ch@cksanitize{#1}#2;% - \ifin@\else\XKV@ch@cksanitize{#1}#2,\fi - \ifin@\@selective@sanitize[0]{,;}#2\fi +\SKV@pdef*\SKV@tfor{\SKV@ifstar\SKV@tfor@b\SKV@tfor@a} +\SKV@pdef*\SKV@tfor@a#1#2#3{% + \SKV@ifblank{#1}{% + \SKV@vbsmsg{warn}{Empty list for '\string\SKV@tfor@a'\on@line}% + }{% + \SKV@ifblank{#3}{% + \SKV@vbsmsg{warn}% + {Empty function for '\string\SKV@tfor@a'\on@line}% + }{% + \SKV@tforloop#1\@nil\@nil{#3}% + }% + }% +} +\SKV@def\SKV@tforloop#1#2#4{% + \long\def#3{#1}% + \SKV@ifstrequal{#1}{\listbreak}{% + \let\SKV@n@xt\SKV@tforrema + }{% + \SKV@ifstrequal{#1}{\@nil}{% + \let\SKV@n@xt\SKV@tfornoop + }{% + #4\relax\let\SKV@n@xt\SKV@tforloop + }% + }% + \SKV@n@xt#2{#4}% +} +\SKV@def\SKV@tfornoop#1#3{} +\SKV@pdef*\SKV@tforrema#1\@nil\@nil#3{% + \long\edef\SKV@remainder{\unexpanded{#1}}% +} +\SKV@pdef*\SKV@tfor@b#1#2#3{\SKV@expnext\SKV@tfor@a{#1}#2{#3}} +\SKV@def*\SKV@preamblecmds{} +\SKV@pdef*\SKV@onlypreamble#1{% + \SKV@tfor{#1}\SKV@resvd{% + \SKV@expnext\SKV@ensurescape\SKV@resvd + \expandafter\gapptomac\expandafter\SKV@preamblecmds + \expandafter{\expandafter\SKV@do@a\SKV@resvd}% + }% +} +\SKV@AfterDocumentStart{% + \gdef\SKV@do@a#1{% + \gdef#1{\SKV@err{'\string#1' is a preamble command}% + {Move command '\string#1' to document preamble.}}% + }% + \SKV@preamblecmds + \global\let\SKV@do@a\@gobble +} +\SKV@pdef*\SKV@onlypackage{% + \SKV@xifempty{\@currname\@currext}{% + \SKV@err{Not in package environment}% + {The command at top level of this message\SKV@MB + is available only in package environment.}% + }{}% } \SKV@def*\SKV@CommandKeyParser#1{% \long\def\SKV@define@keylist##1{% - \ifXKV@st - \long\expandafter\def\expandafter\SKV@tempa\expandafter{##1}% - \else - \long\def\SKV@tempa{##1}% - \fi - \SKV@expandargs{3}\SKV@checksanitizec{{\SKV@expandox{\SKV@tempa}}}% - \SKV@tempa\SKV@nil - \def\SKV@nob{\z@}% - \expandafter\SKV@readkeylist\SKV@tempa#1\SKV@nil + \SKV@undeflt{g}{\skif,\skifx,\skifcase,\skor,\skelse,\skfi}% + \ifswitchon{SKV@st}{% + \long\edef\@keylist{\SKV@expox{##1}}% + }{% + \long\def\@keylist{##1}% + }% + \SKV@resstate + \SKV@expnext\SKV@checksanitizec\@keylist\SKV@tempa + \expandafter\SKV@readkeylist\SKV@tempa#1\@nil }% - \long\def\SKV@readkeylist##1#1##2\SKV@nil{% - \SKV@ifblank{##1}\relax + \long\def\SKV@readkeylist##1#1##2\@nil{% + \SKV@ifblank{##1}{}% {% - \SKV@ifstrequal{##1}{\stopread}{% - \def\SKV@nob{\@ne}% - \stopread##2\SKV@nil + \SKV@ifstrequal{##1}{\listbreak}{% + \SKV@keylistrema##2\@nil#1% }{% - \SKV@define@mult@keys##1\SKV@nil + \SKV@define@multkeys##1\@nil + \SKV@ifblank{##2}\relax{\SKV@readkeylist##2\@nil}% }% }% - \ifnum\SKV@nob=\z@ - \SKV@ifblank{##2}\relax{\SKV@readkeylist##2\SKV@nil}% - \fi }% } -\SKV@def\SKV@expandargs#1#2#3#4\SKV@nil{% - \begingroup - \protected@edef\SKV@tempa{\endgroup - \ifcase#1\relax - \unexpanded{#2}{#3}% - \or - \unexpanded{#2#3}{#4}% - \or - \unexpanded{#2}{#3}{#4}% - \or - \unexpanded{#2}#3\unexpanded{#4}% - \else - \SKV@err{Unknown expansion type '#1' for \string\SKV@expandargs}% - {Use the right expansion identifier (0 - 3)}% - \fi - }% - \SKV@tempa +\SKV@def\SKV@checksanitizec#1#2{% + \XKV@ch@cksanitize{#1}#2;% + \ifin@\else\XKV@ch@cksanitize{#1}#2,\fi + \ifin@\@selective@sanitize[0]{,;}#2\fi } \SKV@pdef\SKV@checkchoice#1#2#3#4{% - \SKV@expandargs{3}{\XKV@cc*+[\val\nr]}{{#1}{#2}}{{#3}{#4}}\SKV@nil + \XKV@sttrue\XKV@pltrue + \SKV@expargs{3}{\XKV@checkchoice[\val\nr]}{{#1}{#2}}{{#3}{#4}}\@nil } \SKV@pdef*\SKV@inputerr#1#2{% \SKV@err{Erroneous value '#1' for key '#2'}{% Please use the correct value for key '#2'.}% } -\SKV@def\SKV@ifblank#1{\SKV@ifbl@nk#1\SKV@nil\SKV@nil\@secondoftwo\@firstoftwo:} -\SKV@def\SKV@ifbl@nk#1#2\SKV@nil#3#4#5:{#4} -\SKV@def\SKV@oifblank#1{\SKV@expandargs{0}\SKV@ifblank{\SKV@expandox{#1}}\SKV@nil} -\SKV@def\SKV@xifblank#1{\SKV@expandargs{0}\SKV@ifblank{#1}\SKV@nil} -\SKV@def\SKV@ifstrequal#1#2{% +\SKV@def*\SKV@despacelist{\SKV@savstate\SKV@testoptd\SKV@despac@list} +\SKV@def*\SKV@despac@list[#1]#2{% \begingroup - \edef\SKV@tempa{\detokenize{#1}}% - \edef\SKV@tempb{\detokenize{#2}}% - \SKV@expandargs{1}\KV@@sp@def\SKV@tempa\SKV@tempa\SKV@nil - \SKV@expandargs{1}\KV@@sp@def\SKV@tempb\SKV@tempb\SKV@nil - \ifx\SKV@tempa\SKV@tempb - \aftergroup\@firstoftwo + \let\SKV@resa\@empty + \ifSKV@st + \def\SKV@dsl{\SKV@for*[#1]#2}% \else - \aftergroup\@secondoftwo + \def\SKV@dsl{\SKV@for[#1]{#2}}% \fi + \SKV@dsl\SKV@dsl{% + \SKV@despace\SKV@dsl + \SKV@appto*\SKV@resa{\expandafter#1\SKV@dsl}% + }% + \ifx\SKV@resa\@empty\else\SKV@remparser[#1]\SKV@resa\fi + \ifSKV@st\global\let#2\SKV@resa\fi \endgroup + \SKV@resstate +} +\SKV@def*\SKV@tdespacelt#1{% + \SKV@tfor{#1}\SKV@dsl{\expandafter\SKV@despace\SKV@dsl}% +} +\SKV@pdef*\ReserveKeyPrefixNames{\SKV@ifstar\SKV@rkpn@mes\SKV@rkpn@m@s} +\SKV@def*\SKV@rkpn@mes#1{\SKV@AfterPackageEnd{\gapptomac\SKV@rkpnames{,#1}}} +\SKV@def*\SKV@rkpn@m@s#1{\gapptomac\SKV@rkpnames{,#1}} +\SKV@pdef*\ReserveMacroPrefixNames{\SKV@ifstar\SKV@rmpn@mes\SKV@rmpn@m@s} +\SKV@def*\SKV@rmpn@mes#1{\SKV@AfterPackageEnd{\gapptomac\SKV@rmpnames{,#1}}} +\SKV@def*\SKV@rmpn@m@s#1{\gapptomac\SKV@rmpnames{,#1}} +\SKV@pdef*\ReserveFamilyNames{\SKV@ifstar\SKV@rfn@mes\SKV@rfn@m@s} +\SKV@def*\SKV@rfn@mes#1{\SKV@AfterPackageEnd{\gapptomac\SKV@rfnames{,#1}}} +\SKV@def*\SKV@rfn@m@s#1{\gapptomac\SKV@rfnames{,#1}} +\SKV@def*\SKV@rkpnames{XKV} +\SKV@def*\SKV@rmpnames{XKV} +\SKV@def*\SKV@rfnames{XKV} +\ReserveKeyPrefixNames*{SKV} +\ReserveMacroPrefixNames*{SKV} +\ReserveFamilyNames*{skeyval} +\SKV@def*\SKV@newlet#1#2{% + \SKV@ifdef#1{% + \SKV@err{Command '\string#1' already defined}% + {I can't let '\string#1' to '\string#2'.}% + }{% + \SKV@ifdef#2{\let#1#2}{% + \SKV@err{Command '\string#2' undefined}% + {I can't let '\string#1' to '\string#2'.}% + }% + }% } -\SKV@def\SKV@oifstrequal#1#2{% - \@expandtwoargs\SKV@ifstrequal{\SKV@expandox{#1}}{\SKV@expandox{#2}}% +\AtEndOfPackage{\SKV@providedef*\NewLet{\SKV@newlet}} +\SKV@pdef*\SKV@cslet{\SKV@savstate\SKV@t@stopta\SKV@@cslet} +\SKV@def*\SKV@@cslet#1#2{% + \ifSKV@st + \def\SKV@n@xt{\SKV@aftercs\let{#1}#2}% + \else + \def\SKV@n@xt{% + \SKV@ifdef{#2}{% + \SKV@aftercs\let{#1}#2% + }{% + \SKV@err{Command '\string#2' undefined}% + {You may use the starred version of \string\SKV@cslet.}% + }% + }% + \fi + \SKV@resstate\SKV@n@xt +} +\SKV@pdef*\SKV@letcs{\SKV@savstate\SKV@t@stopta\SKV@@letcs} +\SKV@def*\SKV@@letcs#1#2{% + \ifSKV@st + \def\SKV@n@xt{% + \begingroup\expandafter\endgroup + \expandafter\let\expandafter#1\csname#2\endcsname + }% + \else + \def\SKV@n@xt{% + \SKV@ifcsdef{#2}{% + \expandafter\let\expandafter#1\csname#2\endcsname + }{% + \SKV@err{Command '\@backslashchar#2' undefined}% + {You may use the starred version of \string\SKV@letcs.}% + }% + }% + \fi + \SKV@resstate\SKV@n@xt +} +\SKV@pdef*\SKV@csletcs{\SKV@savstate\SKV@t@stopta\SKV@@csletcs} +\SKV@def*\SKV@@csletcs#1#2{% + \ifSKV@st + \def\SKV@n@xt{% + \begingroup\expandafter\endgroup + \expandafter\let\csname#1\SKV@aftercs\endcsname{#2}% + }% + \else + \def\SKV@n@xt{% + \SKV@ifcsdef{#2}{% + \SKV@aftercs\let{#1\SKV@aftercs}{#2}% + }{% + \SKV@err{Command '\@backslashchar#2' undefined}% + {You may use the starred version of \string\SKV@csletcs.}% + }% + }% + \fi + \SKV@resstate\SKV@n@xt +} +\SKV@pdef*\SKV@numdef{\SKV@savstate\SKV@testoptc\SKV@@numdef} +\SKV@pdef*\SKV@@numdef{% + \ifSKV@pl + \def\SKV@n@xt##1{\SKV@aftercs\SKV@numd@f{##1}}% + \ifSKV@ask + \let\glob@lrel@x\global + \else + \let\glob@lrel@x\relax + \fi + \else + \let\SKV@n@xt\SKV@numd@f + \ifSKV@ask + \let\glob@lrel@x\global + \else + \let\glob@lrel@x\relax + \fi + \fi + \SKV@resstate\SKV@n@xt } -\SKV@def\SKV@xifstrequal#1#2{\@expandtwoargs\SKV@ifstrequal{#1}{#2}} -\SKV@def\SKV@ifstrempty#1{% - \romannumeral-`\@\csname @\if @\detokenize{#1}@first\else - second\fi oftwo\endcsname +\SKV@pdef*\SKV@numd@f#1#2{% + \SKV@ensurescape@notempty{#1}{#2}% + \SKV@ifundef{#1}{% + \newcount#1\glob@lrel@x#1=\numexpr#2\relax + }{% + \glob@lrel@x#1=\numexpr#2\relax + }% +} +\SKV@pdef*\SKV@dimdef{\SKV@savstate\SKV@testoptc\SKV@@dimdef} +\SKV@pdef*\SKV@@dimdef{% + \ifSKV@pl + \def\SKV@n@xt##1{\SKV@aftercs\SKV@dimd@f{##1}}% + \ifSKV@ask + \let\glob@lrel@x\global + \else + \let\glob@lrel@x\relax + \fi + \else + \let\SKV@n@xt\SKV@dimd@f + \ifSKV@ask + \let\glob@lrel@x\global + \else + \let\glob@lrel@x\relax + \fi + \fi + \SKV@resstate\SKV@n@xt +} +\SKV@pdef*\SKV@dimd@f#1#2{% + \SKV@ensurescape@notempty{#1}{#2}% + \SKV@ifundef{#1}{% + \newdimen#1\glob@lrel@x#1=\dimexpr#2\relax + }{% + \glob@lrel@x#1=\dimexpr#2\relax + }% +} +\SKV@def*\SKV@ensurescape@notempty#1#2{% + \SKV@ensurescape{#1}% + \SKV@ifempty{#2}{\SKV@err{Argument '\string#1' is empty}\@ehc}{}% } -\SKV@def\SKV@oifstrempty#1{% - \SKV@expandargs{0}\SKV@ifstrempty{\SKV@expandox{#1}}\SKV@nil} -\SKV@def\SKV@xifstrempty#1{\SKV@expandargs{0}\SKV@ifstrempty{#1}\SKV@nil} \SKV@def*\SKV@keylistparser@err{% \SKV@err{Key list parser '\SKV@keyparser' not allowed}% {Use semicolon (preferable) or colon as parser.}% @@ -408,37 +1276,33 @@ \define@boolkey+[KV]{skeyval}[SKV@]{xchoicelist}[true]{}{% \SKV@inputerr{#1}{xchoicelist}% } -\define@boolkey+[KV]{skeyval}[SKV@]{inputonce}[true]{}{% - \SKV@inputerr{#1}{inputonce}% -} \define@cmdkey[KV]{skeyval}[SKV@]{genparser}[,]{% \@onelevel@sanitize\SKV@genparser - \SKV@expandargs{1}\KV@@sp@def\SKV@genparser\SKV@genparser\SKV@nil - \SKV@expandargs{0}\SKV@CommandGenParser\SKV@genparser\SKV@nil + \SKV@despace\SKV@genparser + \SKV@expargs{0}\SKV@CommandGenParser\SKV@genparser\@nil } \define@cmdkey[KV]{skeyval}[SKV@]{keyparser}[;]{% \@onelevel@sanitize\SKV@keyparser \SKV@xifblank\SKV@keyparser\SKV@keylistparser@err\relax - \SKV@expandargs{1}\KV@@sp@def\SKV@keyparser\SKV@keyparser\SKV@nil + \SKV@despace\SKV@keyparser \begingroup - \edef\SKV@tempa{\detokenize{,}}% - \ifx\SKV@keyparser\SKV@tempa - \aftergroup\SKV@keylistparser@err - \fi + \SKV@detokdespace{,}\SKV@tempa + \SKV@ifx\SKV@keyparser\SKV@tempa + {\aftergroup\SKV@keylistparser@err}{}% \endgroup - \SKV@expandargs{0}\SKV@CommandKeyParser\SKV@keyparser\SKV@nil + \SKV@expargs{0}\SKV@CommandKeyParser\SKV@keyparser\@nil } \SKV@def*\SKV@keyprefix@err{% \SKV@err{Key prefix '\SKV@keyprefix' is not allowed}% - {Use another prefix instead of '\SKV@keyprefix'.}% + {Use another prefix name instead of '\SKV@keyprefix'.}% } \define@cmdkey[KV]{skeyval}[SKV@]{keyprefix}[KV]{% \SKV@xifblank\SKV@keyprefix\SKV@keyprefix@err\relax - \SKV@expandargs{1}\KV@@sp@def\SKV@keyprefix\SKV@keyprefix\SKV@nil - \SKV@expandargs{3}\XKV@checksanitizeb{{\SKV@rkpnames}}\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \ifx\SKV@keyprefix\SKV@tempa\SKV@afterfi\SKV@keyprefix@err\fi + \SKV@despace\SKV@keyprefix + \SKV@expargs{3}\XKV@checksanitizeb{{\SKV@rkpnames}}% + \SKV@tempa\@nil + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@ifx\SKV@keyprefix\SKV@tempa\SKV@keyprefix@err\relax }% } \SKV@def*\SKV@keyfamily@err{% @@ -447,324 +1311,258 @@ } \define@cmdkey[KV]{skeyval}[SKV@]{keyfamily}[fam]{% \SKV@xifblank\SKV@keyfamily\SKV@keyfamily@err\relax - \SKV@expandargs{1}\KV@@sp@def\SKV@keyfamily\SKV@keyfamily\SKV@nil - \SKV@expandargs{3}\XKV@checksanitizeb{{\SKV@rfnames}}\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \ifx\SKV@keyfamily\SKV@tempa\SKV@afterfi\SKV@keyfamily@err\fi + \SKV@despace\SKV@keyfamily + \SKV@expargs{3}\XKV@checksanitizeb{{\SKV@rfnames}}% + \SKV@tempa\@nil + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@ifx\SKV@keyfamily\SKV@tempa\SKV@keyfamily@err\relax }% } \SKV@def*\SKV@macroprefix@err{% \SKV@err{Macro prefix '\SKV@macroprefix' is not allowed}% - {Use another macro prefix.}% + {Use another macro prefix name instead of '\SKV@macroprefix'.}% } \define@cmdkey[KV]{skeyval}[SKV@]{macroprefix}[mp@]{% \SKV@xifblank\SKV@macroprefix\SKV@macroprefix@err\relax - \SKV@expandargs{1}\KV@@sp@def\SKV@macroprefix\SKV@macroprefix\SKV@nil - \SKV@expandargs{3}\XKV@checksanitizeb{{\SKV@rmpnames}}\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \ifx\SKV@macroprefix\SKV@tempa\SKV@afterfi\SKV@macroprefix@err\fi - }% + \SKV@despace\SKV@macroprefix + \SKV@expargs{3}\XKV@checksanitizeb{{\SKV@rmpnames}}% + \SKV@tempa\@nil + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@ifx\SKV@macroprefix\SKV@tempa\SKV@macroprefix@err\relax + }% +} +\SKV@BeforePackageEnd{\deftog{draft}\deftog{final}} +\define@boolkey+[KV]{skeyval}[SKV@]{draft}[true]{% + \ifSKV@draft + \setkeys[KV]{skeyval}{final=false}% + \SKV@AtPackageEnd{\ifSKV@draft\togtrue{draft}\else + \togfalse{draft}\fi}% + \fi +}{% + \SKV@inputerr{#1}{draft}% +} +\define@boolkey+[KV]{skeyval}[SKV@]{final}[true]{% + \ifSKV@final + \setkeys[KV]{skeyval}{draft=false}% + \SKV@AtPackageEnd{\ifSKV@final\togtrue{final}\else + \togfalse{final}\fi}% + \fi +}{% + \SKV@inputerr{#1}{final}% } \DeclareOptionX*{\SKV@warn{Unknown option '\CurrentOption' ignored}} \ExecuteOptionsX[KV]<skeyval>{genparser,keyparser,keyprefix, - keyfamily,macroprefix,inputonce} + keyfamily,macroprefix,final} \ProcessOptionsX*[KV]<skeyval>\relax \SKV@pdef*\skvoptions#1{\setkeys[KV]{skeyval}{#1}} -\SKV@def*\SKV@despacelist#1#2{% - \SKV@CommandGenParser{#1}% - \let\SKV@tempa#2% - \let#2\@empty - \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@expandargs{1}\KV@@sp@def\SKV@tempa\SKV@tempa\SKV@nil - \SKV@apptomacro@b#2{\expandafter#1\SKV@tempa}% - }% - \ifx#2\@empty\else - \SKV@remparser{#1}#2% - \fi -} -\SKV@def\SKV@named@f#1#2{% - \ifcsname#2\endcsname - \expandafter\ifx\csname#2\endcsname\relax\else - \def\reserved@a{#2}% - \expandafter\expandafter\expandafter\@notdefinable - \fi - \else - \expandafter#1\csname#2\expandafter\endcsname - \fi -} -\SKV@def*\SKV@newnamedef#1{\SKV@named@f\def{#1}} -\SKV@def*\SKV@newnamegdef#1{\SKV@named@f\gdef{#1}} -\SKV@def*\SKV@newnameedef#1{\SKV@named@f\edef{#1}} -\SKV@def*\SKV@newnamexdef#1{\SKV@named@f\xdef{#1}} -\SKV@def*\SKV@namedef#1{\SKV@aftercsname\def{#1}} -\SKV@def*\SKV@namegdef#1{\SKV@aftercsname\gdef{#1}} -\SKV@def*\SKV@nameedef#1{\SKV@aftercsname\edef{#1}} -\SKV@def*\SKV@namexdef#1{\SKV@aftercsname\xdef{#1}} -\SKV@def*\SKV@nameuse#1{% - \ifcsname#1\endcsname\csname#1\expandafter\endcsname\fi} -\SKV@def\SKV@ifnextchar#1#2#3{% - \let\SKV@@tempc=#1\def\SKV@@tempa{#2}\def\SKV@@tempb{#3}% - \futurelet\@temptoks\SKV@ifnextch@r -} -\SKV@def\SKV@ifnextch@r{% - \ifx\@temptoks\SKV@@tempc\let\SKV@@tempb\SKV@@tempa\fi - \SKV@@tempb +\SKV@pdef*\SKV@ifdraft{\@nameuse{@\ifSKV@draft first\else second\fi oftwo}} +\SKV@pdef*\SKV@iffinal{\@nameuse{@\ifSKV@final first\else second\fi oftwo}} +\SKV@pdef*\SKV@ifnotdraft{\SKV@ifdraft\@secondoftwo\@firstoftwo} +\SKV@pdef*\SKV@ifnotfinal{\SKV@iffinal\@secondoftwo\@firstoftwo} +\def\SKV@useinfo#1{Not using '\@backslashchar#1' of 'skyeval' package} +\AtBeginDocument{% + \SKV@ifundef\ifdraft + {\SKV@pdef*\ifdraft{\SKV@ifdraft}}% + {\SKV@vbsmsg{info}{\SKV@useinfo{ifdraft}}}% +} +\SKV@ifundef\ifnotdraft + {\SKV@pdef*\ifnotdraft{\SKV@ifnotdraft}}% + {\SKV@vbsmsg{info}{\SKV@useinfo{ifnotdraft}}} +\SKV@ifundef\iffinal + {\SKV@pdef*\iffinal{\SKV@iffinal}}% + {\SKV@vbsmsg{info}{\SKV@useinfo{iffinal}}} +\SKV@ifundef\ifnotfinal + {\SKV@pdef*\ifnotfinal{\SKV@ifnotfinal}}% + {\SKV@vbsmsg{info}{\SKV@useinfo{ifnotfinal}}} +\SKV@def\SKV@star@or@long#1{% + \SKV@ifstar + {\let\l@ngrel@x\relax\def\@star@or@none{*}#1}% + {\let\l@ngrel@x\long\def\@star@or@none{}#1}% } -\SKV@def\SKV@testopt#1#2{\SKV@ifnextchar[{#1}{#1[{#2}]}} -\SKV@def\SKV@ifstar#1#2{% - \SKV@ifnextchar*{\begingroup - \def\SKV@tempa*{\endgroup #1}\SKV@tempa}{#2}% +\SKV@pdef\requirecmd{\SKV@star@or@long\SKV@require@cmd} +\SKV@def\SKV@require@cmd#1{% + \SKV@ensurescape{#1}% + \SKV@ifdefined{#1}% + {\CheckCommand\@star@or@none}{\newcommand\@star@or@none}{#1}% } -\SKV@def*\SKV@newlet#1#2{% - \SKV@ifdef#1{% - \SKV@err{Command '\string#1' already defined}{% - I can't let '\string#1' to '\string#2'.}% - }{% - \SKV@ifdef#2{% - \let#1#2% - }{% - \SKV@err{Command '\string#2' undefined}{% - I can't let '\string#1' to '\string#2'.}% +\def\@check@eq#1#2{% + \SKV@ifx{#1}{#2}{}{% + \SKV@vbsmsg{warn}{% + Previous definition of '\string#1'\SKV@MB + doesn't match your new definition.\SKV@MB + * I haven't redefined '\string#1' *}% + }% +} +\SKV@pdef*\newswitch#1#2{% + \SKV@ensurenoscape{#1}% + \SKV@ifstrequal{#2}{true}{\def\SKV@resvd{true}}{% + \SKV@ifstrequal{#2}{false}{\def\SKV@resvd{false}}{% + \SKV@ifstrequal{#2}{on}{\def\SKV@resvd{true}}{% + \SKV@ifstrequal{#2}{off}{\def\SKV@resvd{false}}{% + \SKV@swvalerr{#1}{#2}% + }% + }% }% }% -} -\SKV@pdef*\SKV@newtoks#1{\SKV@ifdefinable#1{\@nameuse{newtoks}#1}} -\SKV@pdef*\SKV@newcount#1{\SKV@ifdefinable#1{\@nameuse{newcount}#1}} -\SKV@pdef*\SKV@newdimen#1{\SKV@ifdefinable#1{\@nameuse{newdimen}#1}} -\SKV@def*\nameletcs#1#2{% - \SKV@ifdef{#2}{% - \SKV@aftercsname\let{#1}#2% - }{% - \SKV@err{Command '\string#2' undefined}\@ehc - }% -} -\SKV@def*\csletname#1#2{% - \SKV@ifnamedef{#2}{% - \expandafter\let\expandafter#1\csname#2\endcsname - }{% - \SKV@err{Command '\@backslashchar#2' undefined}\@ehc - }% -} -\SKV@def*\nameletname#1#2{% - \SKV@ifnamedef{#2}{% - %\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname - \SKV@aftercsname\let{#1\SKV@aftercsname}{#2}% - }{% - \SKV@err{Command '\@backslashchar#2' undefined}\@ehc - }% -} -\SKV@def*\@nameletcs#1#2{\SKV@aftercsname\let{#1}#2} -\SKV@def*\@csletname#1#2{% - \begingroup\expandafter\endgroup - \expandafter\let\expandafter#1\csname#2\endcsname -} -\SKV@def*\@nameletname#1#2{% - \begingroup\expandafter\endgroup - \expandafter\let\csname#1\SKV@aftercsname\endcsname{#2}% -} -\SKV@pdef*\SKV@numdef#1#2{% - \SKV@findescape{#1}{}{\SKV@err{Backslash required in '#1'}\@ehc}% - \SKV@ifstrempty{#2}{\SKV@err{Empty argument for counter '#1'}\@ehc}{}% - \SKV@ifundef{#1}{% - \newcount#1#1=\numexpr#2\relax - }{% - #1=\numexpr#2\relax + \expandafter\SKV@ifdefinable\csname if#1\endcsname{% + \csname newif\expandafter\endcsname\csname if#1\endcsname + \csname #1\SKV@resvd\endcsname }% } -\SKV@pdef*\SKV@numnamedef#1{\SKV@aftercsname\SKV@numdef{#1}} -\SKV@pdef*\SKV@numgdef#1#2{% - \SKV@findescape{#1}{}{\SKV@err{Backslash required in '#1'}\@ehc}% - \SKV@ifstrempty{#2}{\SKV@err{Empty argument for counter '#1'}\@ehc}{}% - \SKV@ifundef{#1}{% - \newcount#1\global#1=\numexpr#2\relax +\SKV@newlet\NewSwitches\NewIfs +\SKV@def*\setswitch#1#2{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsundef{if#1}{% + \SKV@noswerr{#1}% }{% - \global#1=\numexpr#2\relax + \SKV@ifstrequal{#2}{true}{\def\SKV@resvd{true}}{% + \SKV@ifstrequal{#2}{false}{\def\SKV@resvd{false}}{% + \SKV@ifstrequal{#2}{on}{\def\SKV@resvd{true}}{% + \SKV@ifstrequal{#2}{off}{\def\SKV@resvd{false}}{% + \SKV@swvalerr{#1}{#2}% + }% + }% + }% + }% + \csname#1\SKV@resvd\endcsname }% } -\SKV@pdef*\SKV@numnamegdef#1{\SKV@aftercsname\SKV@numgdef{#1}} -\SKV@pdef*\SKV@dimdef#1#2{% - \SKV@findescape{#1}{}{\SKV@err{Backslash required in '#1'}\@ehc}% - \SKV@ifstrempty{#2}{\SKV@err{Empty argument for dimension '#1'}\@ehc}{}% - \SKV@ifundef{#1}{% - \newdimen#1#1=\dimexpr#2\relax - }{% - #1=\dimexpr#2\relax - }% +\SKV@def*\switchon#1{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsundef{if#1}{\SKV@noswerr{#1}}{\@nameuse{#1true}}% } -\SKV@pdef*\SKV@dimnamedef#1{\SKV@aftercsname\SKV@dimdef{#1}} -\SKV@pdef*\SKV@dimgdef#1#2{% - \SKV@findescape{#1}{}{\SKV@err{Backslash required in '#1'}\@ehc}% - \SKV@ifstrempty{#2}{\SKV@err{Empty argument for dimension '#1'}\@ehc}{}% - \SKV@ifundef{#1}{% - \newdimen#1\global#1=\dimexpr#2\relax - }{% - \global#1=\dimexpr#2\relax - }% +\SKV@newlet\switchtrue\switchon +\SKV@def*\switchoff#1{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsundef{if#1}{\SKV@noswerr{#1}}{\@nameuse{#1false}}% } -\SKV@pdef*\SKV@dimnamegdef#1{\SKV@aftercsname\SKV@dimgdef{#1}} -\SKV@pdef*\define@compboolkeys{% - \let\SKV@def@boolkey\define@boolkey - \SKV@testopt{\SKV@compbool@opta}{KV}% +\SKV@newlet\switchfalse\switchoff +\SKV@def*\ifswitchon#1{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsundef{if#1}{\SKV@noswerr{#1}\@gobbletwo}% + {\@nameuse{@\@nameuse{if#1}first\else second\fi oftwo}}% } -\SKV@pdef*\newcompboolkeys{% - \let\SKV@def@boolkey\newboolkey - \SKV@testopt{\SKV@compbool@opta}{KV}% -} -\SKV@def*\SKV@compbool@opta[#1]#2{% - \SKV@testopt{\SKV@define@compboolkeys[#1]{#2}}{mp@}} -\SKV@def\SKV@define@compboolkeys[#1]#2[#3]#4[#5]#6#7#8{% - \SKV@namedef{#1@#2@#4@func}{% - #7\SKV@nameuse{if#3#4}\SKV@nameuse{#3#6false}\else - \SKV@nameuse{#3#6true}\fi}% - \SKV@namedef{#1@#2@#6@func}{% - #8\SKV@nameuse{if#3#6}\SKV@nameuse{#3#4false}\else - \SKV@nameuse{#3#4true}\fi}% - \begingroup\protected@edef\SKV@tempa{\endgroup - \unexpanded{% - \SKV@def@boolkey+[#1]{#2}[#3]{#4}[#5]{% - \SKV@nameuse{#1@#2@#4@func}% - }{% - \SKV@inputerr{##1}{#4}% - }% - \SKV@def@boolkey+[#1]{#2}[#3]{#6}[#5]{% - \SKV@nameuse{#1@#2@#6@func}% - }{% - \SKV@inputerr{##1}{#6}% - }% - }% - }% - \SKV@tempa +\SKV@newlet\ifswitchtrue\ifswitchon +\SKV@def*\ifswitchoff#1{% + \SKV@ensurenoscape{#1}% + \SKV@ifcsundef{if#1}{\SKV@noswerr{#1}\@gobbletwo}% + {\@nameuse{@\@nameuse{if#1}second\else first\fi oftwo}}% } -\SKV@def\SKV@star@or@long#1{% - \SKV@ifstar{% - \let\l@ngrel@x\relax - \def\SKV@star@or@none{*}#1% - }{% - \let\l@ngrel@x\long - \def\SKV@star@or@none{}#1% - }% +\SKV@newlet\ifswitchfalse\ifswitchoff +\SKV@pdef*\SKV@noswerr#1{% + \SKV@err{Switch '\string#1' is undefined}% + {You need to first define the switch '\string#1'.}% } -\SKV@pdef\requirecmd{\SKV@star@or@long\SKV@require@cmd} -\SKV@def\SKV@require@cmd#1{% - \ifdefined#1% - \SKV@afterelsefi - \expandafter\CheckCommand\SKV@star@or@none - \else - \SKV@afterfi - \expandafter\newcommand\SKV@star@or@none - \fi - {#1}% +\SKV@def*\SKV@swvalerr#1#2{% + \SKV@err{Invalid switch value '#2' for switch '\string#1'}% + {Valid switch values are 'true', 'on', 'false', and 'off'.}% } -\def\@check@eq#1#2{% - \unless\ifx#1#2% - \SKV@warn{% - Previous definition of \string#1\MessageBreak - doesn't match your new definition.\MessageBreak - *** I haven't redefined \string#1\space *** - }% - \fi -} -\SKV@pdef*\SKV@undeftoggle@err#1{% +\SKV@pdef*\SKV@undeftog@err#1{% \SKV@err{Toggle '#1' undefined}% {You need to first define '#1' before use.}% } \SKV@pdef*\deftog#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \SKV@warn{Toggle '#1' redefined\on@line}% - }{}% - \nameletcs{SKV@toggle@#1}\@secondoftwo + \SKV@ifcsundef{SKV@toggle@#1}{}{% + \SKV@vbsmsg{warn}{Toggle '#1' redefined\on@line}% + }% + \SKV@aftercs\let{SKV@toggle@#1}\@secondoftwo } \SKV@pdef*\newtog#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% + \SKV@ifcsdef{SKV@toggle@#1}{% \SKV@err{Toggle '#1' already defined}% {Please provide a new toggle or redefine '#1'.}% - }{% - \nameletcs{SKV@toggle@#1}\@secondoftwo - }% + }{\SKV@aftercs\let{SKV@toggle@#1}\@secondoftwo}% } \SKV@pdef*\providetog#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \SKV@info{Toggle '#1' already defined.\MessageBreak - Not redefined\on@line}% - }{% - \nameletcs{SKV@toggle@#1}\@secondoftwo - }% -} -\SKV@pdef*\requiretog#1{% - \SKV@aftercsname\requirecmd{SKV@toggle@#1}[2]{##2}% -} -\SKV@pdef*\settog#1#2{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \SKV@ifnamedef{SKV@t@ggle#2}{% - \nameletname{SKV@toggle@#1}{SKV@t@ggle#2}% + \SKV@ifcsdef{SKV@toggle@#1}{% + \SKV@vbsmsg{info}% + {Toggle '#1' already defined.\SKV@MB Not redefined\on@line}% + }{\SKV@aftercs\let{SKV@toggle@#1}\@secondoftwo}% +} +\SKV@pdef*\requiretog#1{\SKV@aftercs\requirecmd{SKV@toggle@#1}[2]{##2}} +\SKV@def*\settog#1#2{% + \SKV@ifcsdef{SKV@toggle@#1}{% + \SKV@ifcsdef{SKV@t@ggle#2}{% + \SKV@aftercs\let{SKV@toggle@#1\expandafter}% + \csname SKV@t@ggle#2\endcsname }{% - \SKV@err{% - Inadmissible value '#2' for toggle '#1' - }{% - Valid values for toggles are 'true' and 'false'. - }% + \SKV@err{Inadmissible value '#2' for toggle '#1'}% + {Valid values for toggles are 'true' and 'false'.}% }% - }{% - \SKV@undeftoggle@err{#1}% - }% + }{\SKV@undeftog@err{#1}}% } -\SKV@pdef*\togtrue#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \nameletcs{SKV@toggle@#1}\SKV@t@ggletrue - }{% - \SKV@undeftoggle@err{#1}% - }% +\SKV@def*\togtrue#1{% + \SKV@ifcsdef{SKV@toggle@#1}{% + \expandafter\let\csname SKV@toggle@#1\endcsname\SKV@t@ggletrue + }{\SKV@undeftog@err{#1}}% } -\SKV@pdef*\togfalse#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \nameletcs{SKV@toggle@#1}\SKV@t@gglefalse +\SKV@def*\togfalse#1{% + \SKV@ifcsdef{SKV@toggle@#1}{% + \expandafter\let\csname SKV@toggle@#1\endcsname\SKV@t@gglefalse }{% - \SKV@undeftoggle@err{#1}% + \SKV@undeftog@err{#1}% }% } \SKV@newlet\SKV@t@ggletrue\@firstoftwo \SKV@newlet\SKV@t@gglefalse\@secondoftwo -\SKV@pdef*\iftog#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \@nameuse{SKV@toggle@#1}% - }{% - \SKV@undeftoggle@err{#1}% - }% +\SKV@def*\iftog#1{% + \SKV@ifcsdef{SKV@toggle@#1}{\@nameuse{SKV@toggle@#1}}% + {\SKV@undeftog@err{#1}}% +} +\SKV@def*\ifnottog#1{% + \SKV@ifcsdef{SKV@toggle@#1}{% + \@nameuse{SKV@toggle@#1}\@secondoftwo\@firstoftwo}% + {\SKV@undeftog@err{#1}\@gobbletwo}% +} +\deftog{pdf} +\SKV@ifundef\pdfoutput{}{% + \ifnum\pdfoutput<\@ne + \SKV@pdef*\SKV@ifpdf{\@secondoftwo}% + \else + \togtrue{pdf}% + \SKV@pdef*\SKV@ifpdf{\@firstoftwo}% + \fi + \SKV@pdef*\SKV@ifnotpdf{\SKV@ifpdf\@secondoftwo\@firstoftwo}% } -\SKV@pdef*\ifnottog#1{% - \SKV@ifnamedef{SKV@toggle@#1}{% - \@nameuse{SKV@toggle@#1}\@secondoftwo\@firstoftwo - }{% - \SKV@undeftoggle@err{#1}\@gobbletwo - }% +\SKV@ifundef\ifnotpdf + {\let\ifnotpdf\SKV@ifnotpdf}% + {\SKV@vbsmsg{info}{\SKV@useinfo{ifnotpdf}}} +\SKV@AtDocumentStart{% + \SKV@ifundef\ifpdf + {\SKV@pdef*\ifpdf{\SKV@ifpdf}}% + {\SKV@vbsmsg{info}{\SKV@useinfo{ifpdf}}}% } \SKV@pdef*\SKV@definedkey@err#1{% - \SKV@ifnamedef{\XKV@header#1}{% - \SKV@err{% - Key '#1' already defined in family '\XKV@tfam' - }{% - Use another key name for '#1'. - }% - }{}% + \SKV@ifcsundef{\XKV@header#1}{}{% + \SKV@err{Key '#1' already defined in family '\XKV@tfam'\SKV@MB + with prefix '\SKV@pref'}{Use another key name instead of '#1'.}% + }% } +\SKV@pdef*\define@menukey{\define@choicekey} \SKV@pdef*\define@togkey{\XKV@t@stopta{\XKV@testoptd\SKV@define@togkey{}}} \SKV@def*\SKV@define@togkey#1#2[#3]{% - \SKV@reservedkey@err{#2}% - \SKV@suspendedkey@err{#2}% + \SKV@findkeypointers{#2}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + \SKV@csundef{SKV@toggle@#1\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa \ifXKV@pl - \SKV@afterelsefi - \expandafter\SKV@d@f@ne@togkey + \def\SKV@n@xt{\SKV@aftercs\SKV@d@f@ne@togkey}% \else - \SKV@afterfi - \expandafter\SKV@d@fine@togkey + \def\SKV@n@xt{\SKV@aftercs\SKV@d@fine@togkey}% \fi - \csname\XKV@header#2\endcsname{#2}{#1#2}{#3}% + \begingroup + \edef\SKV@tempa{\endgroup + {\XKV@header\SKV@resa}{\SKV@resa}{#1\SKV@resa}{#3}}% + \aftergroup\SKV@n@xt\SKV@tempa } \SKV@def*\SKV@d@fine@togkey#1#2#3#4#5{% - \SKV@d@f@ne@t@gkey#1{#2}{#3}{#4}% - {{\settog{#3}{\XKV@resa}#5}}% + \SKV@d@f@ne@t@gkey#1{#2}{#3}{#4}{{\settog{#3}{\XKV@resa}#5}}% } \SKV@def*\SKV@d@f@ne@togkey#1#2#3#4#5#6{% \SKV@d@f@ne@t@gkey#1{#2}{#3}{#4}% @@ -783,367 +1581,651 @@ }% \fi } -\SKV@pdef*\define@togkeys{% - \XKV@plfalse\XKV@testoptd\SKV@define@togkeys{}} +\SKV@pdef*\define@togkeys{\XKV@plfalse\XKV@testoptd\SKV@define@togkeys{}} \SKV@def*\SKV@define@togkeys#1#2[#3]{% - \XKV@sp@deflist\SKV@tempa{#2}% - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@expandargs{3}\SKV@d@fine@togkeys{{\SKV@tempa}}{{#1}{#3}}\SKV@nil + \SKV@despacelist{#2}% + \SKV@for*[,]\SKV@resa\SKV@tempa{% + \SKV@expargs{3}% + \SKV@d@fine@togkeys{{\SKV@tempa}}{{#1}{#3}}\@nil }% } \SKV@def*\SKV@d@fine@togkeys#1#2#3{% - \SKV@aftercsname\SKV@d@f@ne@t@gkey{\XKV@header#1}% - {#1}{#2#1}{#3}{{\settog{#2#1}{\XKV@resa}}}% + \SKV@findkeypointers{#1}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + \SKV@csundef{SKV@toggle@#2\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa + \edef\SKV@tempa{% + \noexpand\SKV@d@f@ne@t@gkey\@nameuse{\XKV@header\SKV@resa}% + {\SKV@resa}{#2\SKV@resa}{#3}% + {{\noexpand\settog{#2\SKV@resa}{\noexpand\XKV@resa}}}% + }% + \SKV@tempa } \SKV@pdef*\newordkey{\XKV@testoptb\SKV@newordkey} \SKV@def*\SKV@newordkey#1{% - \SKV@definedkey@err{#1}% - \SKV@ifnextchar[{\XKV@d@fine@k@y{#1}}% - {\SKV@namedef{\XKV@header#1}####1}% + \SKV@findkeypointers{#1}% + \SKV@expnext\SKV@definedkey@err\SKV@resa + \begingroup + \edef\SKV@tempa{\endgroup + \SKV@ifbrack{\noexpand\XKV@d@fine@key{\SKV@resa}}% + {\noexpand\SKV@d@fine@key{\SKV@resa}}% + }% + \SKV@tempa } \SKV@pdef*\newcmdkey{\XKV@testoptd\SKV@newcmdkey{cmd}} \SKV@def*\SKV@newcmdkey#1#2[#3]#4{% - \SKV@definedkey@err{#2}% - \ifXKV@st\XKV@define@default{#2}{#3}\fi - \edef\SKV@tempa{\noexpand\def\@nameuse{\XKV@header#2}####1}% - \edef\SKV@tempb{\noexpand\def\@nameuse{#1#2}\unexpanded{{##1}#4}}% - \expandafter\SKV@tempa\expandafter{\SKV@tempb}% - \SKV@undef\SKV@tempa\SKV@undef\SKV@tempb + \SKV@findkeypointers{#2}% + \SKV@expnext\SKV@definedkey@err\SKV@resa + \ifXKV@st + \SKV@afterfi + \SKV@expnext\XKV@define@default\SKV@resa{#3}% + \fi + \begingroup + \edef\SKV@tempa{\noexpand\def\@nameuse{\XKV@header\SKV@resa}####1}% + \edef\SKV@tempb{\noexpand\def\@nameuse{#1\SKV@resa}% + \unexpanded{{##1}#4}}% + \expandafter\expandafter\expandafter\endgroup + \expandafter\SKV@tempa\expandafter{\SKV@tempb}% } \SKV@pdef*\newcmdkeys{\XKV@testoptd\SKV@newcmdkeys{cmd}} \SKV@def*\SKV@newcmdkeys#1#2[#3]{% - \XKV@sp@deflist\SKV@tempa{#2}% - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% + \SKV@despacelist{#2}% + \SKV@for*[,]\SKV@resa\SKV@tempa{% \edef\SKV@tempa{\noexpand\SKV@newcmdkey{#1}{\SKV@tempa}}% \SKV@tempa[#3]{}% }% } \SKV@pdef*\newchoicekey{\XKV@testopta{\XKV@testoptb\SKV@newchoicekey}} \SKV@def*\SKV@newchoicekey#1{% - \SKV@definedkey@err{#1}% - \@testopt{\XKV@d@fine@choicekey{#1}}{}% + \SKV@findkeypointers{#1}% + \SKV@expnext\SKV@definedkey@err\SKV@resa + \begingroup + \edef\SKV@tempa##1{\endgroup\SKV@testopt{##1{\SKV@resa}}{}}% + \SKV@tempa\XKV@d@fine@choicekey } +\let\newmenukey\newchoicekey \SKV@pdef*\newboolkey{\XKV@t@stopta{\XKV@testoptd\SKV@newboolkey{}}} \SKV@def*\SKV@newboolkey#1#2[#3]{% - \SKV@definedkey@err{#2}% + \SKV@findkeypointers{#2}% + \SKV@expnext\SKV@definedkey@err\SKV@resa \ifXKV@pl - \SKV@afterelsefi - \expandafter\XKV@d@f@ne@boolkey + \def\SKV@n@xt{\SKV@aftercs\XKV@d@f@ne@boolkey}% \else - \SKV@afterfi - \expandafter\XKV@d@fine@boolkey + \def\SKV@n@xt{\SKV@aftercs\XKV@d@fine@boolkey}% \fi - \csname\XKV@header#2\endcsname{#2}{#1#2}{#3}% + \edef\SKV@tempa{{\XKV@header\SKV@resa}{\SKV@resa}{#1\SKV@resa}{#3}}% + \expandafter\SKV@n@xt\SKV@tempa } \SKV@pdef*\newboolkeys{\XKV@plfalse\XKV@testoptd\SKV@newboolkeys{}} \SKV@def*\SKV@newboolkeys#1#2[#3]{% - \XKV@sp@deflist\SKV@tempa{#2}% - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% + \SKV@despacelist{#2}% + \SKV@for*[,]\SKV@resa\SKV@tempa{% \SKV@definedkey@err\SKV@tempa - \SKV@expandargs{3}\XKV@d@fine@boolkeys{{\SKV@tempa}}{{#1}{#3}}\SKV@nil + \SKV@expargs{3}% + \XKV@d@fine@boolkeys{{\SKV@tempa}}{{#1}{#3}}\@nil }% } \SKV@pdef*\newtogkey{\XKV@t@stopta{\XKV@testoptd\SKV@newtogkey{}}} \SKV@def*\SKV@newtogkey#1#2[#3]{% - \SKV@definedkey@err{#2}% + \SKV@findkeypointers{#2}% + \SKV@expnext\SKV@definedkey@err\SKV@resa \ifXKV@pl - \SKV@afterelsefi - \expandafter\SKV@d@f@ne@togkey + \def\SKV@n@xt{\SKV@aftercs\SKV@d@f@ne@togkey}% \else - \SKV@afterfi - \expandafter\SKV@d@fine@togkey + \def\SKV@n@xt{\SKV@aftercs\SKV@d@fine@togkey}% \fi - \csname\XKV@header#2\endcsname{#2}{#1#2}{#3}% + \begingroup + \edef\SKV@tempa{\endgroup + {\XKV@header\SKV@resa}{\SKV@resa}{#1\SKV@resa}{#3}}% + \aftergroup\SKV@n@xt\SKV@tempa } \SKV@pdef*\newtogkeys{\XKV@plfalse\XKV@testoptd\SKV@newtogkeys{}} \SKV@def*\SKV@newtogkeys#1#2[#3]{% - \XKV@sp@deflist\SKV@tempa{#2}% - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% + \SKV@despacelist{#2}% + \SKV@for*[,]\SKV@resa\SKV@tempa{% \SKV@definedkey@err\SKV@tempa - \SKV@expandargs{3}\SKV@d@fine@togkeys{{\SKV@tempa}}{{#1}{#3}}\SKV@nil + \SKV@expargs{3}\SKV@d@fine@togkeys{{\SKV@tempa}}{{#1}{#3}}\@nil + }% +} +\SKV@pdef*\define@biboolkeys{\SKV@compopta\define@boolkey\SKV@biboolkeys} +\SKV@pdef*\newbiboolkeys{\SKV@compopta\newboolkey\SKV@biboolkeys} +\SKV@pdef*\define@uniboolkeys{\SKV@compopta\define@boolkey\SKV@uniboolkeys} +\SKV@pdef*\newuniboolkeys{\SKV@compopta\newboolkey\SKV@uniboolkeys} +\SKV@pdef*\define@biuniboolkeys{% + \SKV@savstate + \SKV@t@stoptb{\SKV@compopta\define@boolkey\SKV@biuniboolkeys}% +} +\SKV@pdef*\newbiuniboolkeys{% + \SKV@savstate + \SKV@t@stoptb{\SKV@compopta\newboolkey\SKV@biuniboolkeys}% +} +\SKV@pdef*\define@bitogkeys{\SKV@compopta\define@togkey\SKV@bitogkeys} +\SKV@pdef*\newbitogkeys{\SKV@compopta\newtogkey\SKV@bitogkeys} +\SKV@pdef*\define@unitogkeys{\SKV@compopta\define@togkey\SKV@unitogkeys} +\SKV@pdef*\newunitogkeys{\SKV@compopta\newtogkey\SKV@unitogkeys} +\SKV@pdef*\define@biunitogkeys{% + \SKV@savstate + \SKV@t@stoptb{\SKV@compopta\define@togkey\SKV@biunitogkeys}% +} +\SKV@pdef*\newbiunitogkeys{% + \SKV@savstate + \SKV@t@stoptb{\SKV@compopta\newtogkey\SKV@biunitogkeys}% +} +\SKV@def*\SKV@compopta#1#2{% + \let\SKV@c@mpkey#1\let\SKV@co@pkey#2% + \SKV@testopt{\SKV@compoptb}{KV}% +} +\SKV@def*\SKV@compoptb[#1]#2{\SKV@testopt{\SKV@compoptc[#1]{#2}}{mp@}} +\SKV@def*\SKV@compoptc[#1]#2[#3]#4{% + \SKV@testopt{\SKV@co@pkey[#1]{#2}[#3]{#4}}{true}} +\SKV@def*\SKV@biboolkeys[#1]#2[#3]#4[#5]#6#7#8{% + \@namedef{#1@#2@#4@func}{% + #7\relax + \ifswitchon{#3#4}{\switchoff{#3#6}}{\switchon{#3#6}#8\relax}% + }% + \@namedef{#1@#2@#6@func}{% + #8\relax + \ifswitchon{#3#6}{\switchoff{#3#4}}{\switchon{#3#4}#7\relax}% + }% + \SKV@compk@y{#1}{#2}{#3}{#4}{#5}{#6}% +} +\SKV@def*\SKV@uniboolkeys[#1]#2[#3]#4[#5]#6#7#8{% + \@namedef{#1@#2@#4@func}{% + #7\relax + \ifswitchon{#3#4}{\switchon{#3#6}#8\relax}{\switchoff{#3#6}}% + }% + \@namedef{#1@#2@#6@func}{% + #8\relax + \ifswitchon{#3#6}{\switchon{#3#4}#7\relax}{\switchoff{#3#4}}% + }% + \SKV@compk@y{#1}{#2}{#3}{#4}{#5}{#6}% +} +\SKV@def*\SKV@biuniboolkeys[#1]#2[#3]#4[#5]#6#7#8{% + \SKV@aftercs\def{#1@#2@#6@func}{#8\relax}% + \ifswitchon{SKV@st}{% + \ifswitchon{SKV@pl}{% + \@namedef{#1@#2@#4@func}{% + #7\relax\ifswitchon{#3#4}{}{\switchoff{#3#6}}% + }% + }{% + \@namedef{#1@#2@#4@func}{% + #7\relax + \ifswitchon{#3#4}{}{\switchon{#3#6}\@nameuse{#1@#2@#6@func}}% + }% + }% + }{% + \ifswitchon{SKV@pl}{% + \@namedef{#1@#2@#4@func}{% + #7\relax\ifswitchon{#3#4}{\switchoff{#3#6}}{}% + }% + }{% + \@namedef{#1@#2@#4@func}{% + #7\relax + \ifswitchon{#3#4}{\switchon{#3#6}\@nameuse{#1@#2@#6@func}}{}% + }% + }% }% + \SKV@resstate + \SKV@compk@y{#1}{#2}{#3}{#4}{#5}{#6}% } -\SKV@pdef*\define@comptogkeys{% - \let\SKV@def@togkey\define@togkey - \SKV@testopt{\SKV@comptog@opta}{KV}% +\SKV@def*\SKV@bitogkeys[#1]#2[#3]#4[#5]#6#7#8{% + \@namedef{#1@#2@#4@func}{% + #7\relax + \iftog{#3#4}{\togfalse{#3#6}}{\togtrue{#3#6}#8\relax}% + }% + \@namedef{#1@#2@#6@func}{% + #8\relax + \iftog{#3#6}{\togfalse{#3#4}}{\togtrue{#3#4}#7\relax}% + }% + \SKV@compk@y{#1}{#2}{#3}{#4}{#5}{#6}% } -\SKV@pdef*\newcomptogkeys{% - \let\SKV@def@togkey\newtogkey - \SKV@testopt{\SKV@comptog@opta}{KV}% -} -\SKV@def*\SKV@comptog@opta[#1]#2{% - \SKV@testopt{\SKV@define@comptogkeys[#1]{#2}}{mp@}} -\SKV@def\SKV@define@comptogkeys[#1]#2[#3]#4[#5]#6#7#8{% - \SKV@namedef{#1@#2@#4@func}{% - #7\iftog{#3#4}{\togfalse{#3#6}}{\togtrue{#3#6}}}% - \SKV@namedef{#1@#2@#6@func}{% - #8\iftog{#3#6}{\togfalse{#3#4}}{\togtrue{#3#4}}}% - \begingroup\protected@edef\SKV@tempa{\endgroup - \unexpanded{% - \SKV@def@togkey+[#1]{#2}[#3]{#4}[#5]{% - \SKV@nameuse{#1@#2@#4@func}% - }{% - \SKV@inputerr{##1}{#4}% +\SKV@def*\SKV@unitogkeys[#1]#2[#3]#4[#5]#6#7#8{% + \@namedef{#1@#2@#4@func}{% + #7\relax + \iftog{#3#4}{\togtrue{#3#6}#8\relax}{\togfalse{#3#6}}% + }% + \@namedef{#1@#2@#6@func}{% + #8\relax + \iftog{#3#6}{\togtrue{#3#4}#7\relax}{\togfalse{#3#4}}% + }% + \SKV@compk@y{#1}{#2}{#3}{#4}{#5}{#6}% +} +\SKV@def*\SKV@biunitogkeys[#1]#2[#3]#4[#5]#6#7#8{% + \@namedef{#1@#2@#6@func}{#8}% + \ifswitchon{SKV@st}{% + \ifswitchon{SKV@pl}{% + \@namedef{#1@#2@#4@func}{% + #7\relax\ifnottog{#3#4}{\togfalse{#3#6}}{}% }% - \SKV@def@togkey+[#1]{#2}[#3]{#6}[#5]{% - \SKV@nameuse{#1@#2@#6@func}% - }{% - \SKV@inputerr{##1}{#6}% + }{% + \@namedef{#1@#2@#4@func}{% + #7\relax\ifnottog{#3#4}{\togtrue{#3#6}#8\relax}{}% + }% + }% + }{% + \ifswitchon{SKV@pl}{% + \@namedef{#1@#2@#4@func}{% + #7\relax\iftog{#3#4}{\togfalse{#3#6}}{}% + }% + }{% + \@namedef{#1@#2@#4@func}{% + #7\relax\iftog{#3#4}{\togtrue{#3#6}#8\relax}{}% }% }% }% - \SKV@tempa + \SKV@resstate + \SKV@compk@y{#1}{#2}{#3}{#4}{#5}{#6}% +} +\SKV@def*\SKV@compk@y#1#2#3#4#5#6{% + \SKV@c@mpkey+[#1]{#2}[#3]{#4}[#5]{\@nameuse{#1@#2@#4@func}}% + {\SKV@inputerr{##1}{#4}}% + \SKV@c@mpkey+[#1]{#2}[#3]{#6}[#5]{\@nameuse{#1@#2@#6@func}}% + {\SKV@inputerr{##1}{#6}}% +} +\SKV@pdef*\SKV@keylistrema#1\@nil#2{% + \long\edef\SKV@remainder{\unexpanded{#1}}% + \SKV@oifblank{\SKV@remainder}{}{% + \def\SKV@tempa##1#2\@nil{\def\SKV@remainder{##1}}% + \expandafter\SKV@tempa\SKV@remainder\@nil + }% } -\SKV@pdef*\stopread#1\SKV@nil{\long\edef\SKV@remainder{\unexpanded{#1}}} -\def\SKV@noa{\z@}\def\SKV@nob{\z@}\def\SKV@noc{\z@} \SKV@pdef*\define@keylist{% - \let\SKV@def@key\define@key + \let\SKV@def@ordkey\define@key \let\SKV@def@cmdkey\define@cmdkey \let\SKV@def@boolkey\define@boolkey \let\SKV@def@togkey\define@togkey \let\SKV@def@choicekey\define@choicekey - \SKV@ifstar{\XKV@sttrue\SKV@define@keylist}% - {\XKV@stfalse\SKV@define@keylist}% + \SKV@savstate + \SKV@t@stopta\SKV@define@keylist } \SKV@pdef*\newkeylist{% - \let\SKV@def@key\newordkey + \let\SKV@def@ordkey\newordkey \let\SKV@def@cmdkey\newcmdkey \let\SKV@def@boolkey\newboolkey \let\SKV@def@togkey\newtogkey \let\SKV@def@choicekey\newchoicekey - \SKV@ifstar{\XKV@sttrue\SKV@define@keylist}% - {\XKV@stfalse\SKV@define@keylist}% -} -\SKV@def\ChoiceKeyValues#1#2{% - \ifSKV@xchoicelist - \SKV@nameedef{\SKV@keyprefix @\SKV@keyfamily @#1@altlist}{#2}% + \SKV@savstate + \SKV@t@stopta\SKV@define@keylist +} +\SKV@def*\choicekeyvalues{% + \SKV@t@stopta{\SKV@testopt\SKV@choic@keyvalues\SKV@keyprefix}} +\SKV@def*\SKV@choic@keyvalues[#1]{% + \SKV@testopt{\SKV@choic@keyv@lues[#1]}\SKV@keyfamily} +\SKV@def*\SKV@choic@keyv@lues[#1][#2]#3#4{% + \ifSKV@st + \SKV@csedef{#1@#2@#3@altlist}{#4}% \else - \SKV@ifnameundef{\SKV@keyprefix @\SKV@keyfamily @#1@altlist}{% - \SKV@newnameedef{\SKV@keyprefix @\SKV@keyfamily @#1@altlist}{#2}% + \SKV@ifcsundef{#1@#2@#3@altlist}{% + \SKV@csedef{#1@#2@#3@altlist}{#4}% }{% - \SKV@err{% - You have attempted to set two \MessageBreak - \string\ChoiceKeyValues\space for the choice\MessageBreak - key '#1' in the same family '\SKV@keyfamily' - }{% - You can only do that if you set 'xchoicelist'=true. - }% + \SKV@err + {Problem with \string\choicekeyvalues\space for key '#3'}% + {You have attempted to set two \string\choicekeyvalues\SKV@MB + for choice key '#3' in the same family '#2'\SKV@MB + with the same prefix '#1'. You can only do\SKV@MB + that if you use the starred variant of \string\choicekeyvalues.}% }% \fi } -\SKV@newlet\CKVS\ChoiceKeyValues +\SKV@newlet\CKVS\choicekeyvalues \SKV@def*\SKV@detok@z@p#1{% - \edef#1{\expandafter\detokenize\expandafter{#1}\space}% + \edef#1{\detokenize\expandafter{#1}\space}% \edef#1{\expandafter\zap@space#1\@empty}% } \SKV@def*\SKV@detok@zsp#1{% + \SKV@ensurescape{#1}% \begingroup - \def\SKV@no{\z@}% - \SKV@CommandGenParser{,}% - \SKV@for@b#1\SKV@tempa{% - \edef\SKV@no{\the\numexpr\SKV@no+\@ne}% - \edef\SKV@tempa{\expandafter\detokenize\expandafter{\SKV@tempa}\space}% + \SKV@for*[,]#1\SKV@tempa{% + \edef\SKV@tempa{\detokenize\expandafter{\SKV@tempa}\space}% \edef\SKV@tempa{\expandafter\zap@space\SKV@tempa\@empty}% - \SKV@namexdef{SKV@zsp\SKV@no}{\SKV@expandox{\SKV@tempa}}% + \SKV@aftercs\xdef{SKV@zsp@\expandafter + \@gobble\SKV@tempa}{\SKV@expox{\SKV@tempa}}% }% \endgroup } \SKV@def*\SKV@detok@dsp#1{% + \SKV@ensurescape{#1}% \begingroup - \def\SKV@no{\z@}% - \SKV@CommandGenParser{,}% - \SKV@for@b#1\SKV@tempa{% - \edef\SKV@no{\the\numexpr\SKV@no+\@ne}% - \edef\SKV@tempa{\expandafter\detokenize\expandafter{\SKV@tempa}}% - \SKV@expandargs{1}\KV@@sp@def\SKV@tempa\SKV@tempa\SKV@nil - \SKV@namexdef{SKV@dsp\SKV@no}{\SKV@expandox{\SKV@tempa}}% + \SKV@for*[,]#1\SKV@tempa{% + \edef\SKV@tempa{\detokenize\expandafter{\SKV@tempa}}% + \SKV@despace\SKV@tempa + \SKV@aftercs\xdef{SKV@dsp@\expandafter + \@gobble\SKV@tempa}{\SKV@expox{\SKV@tempa}}% }% \endgroup } -\SKV@def*\SKV@if@err{% - \SKV@err{You can't use '\protect\if' and '\protect\fi' in key macro}% - {Use '\protect\fif' and '\protect\ffi' instead.}% -} -\SKV@def\SKV@define@mult@keys#1,#2,#3,#4\SKV@nil{% +\SKV@def*\SKV@exceplist{\par,\if,\ifcase,\or,\else,\skif,\iftog,\ifswitch} +\SKV@detok@dsp\SKV@exceplist +\SKV@def*\SKV@noiferr#1#2{% + \SKV@err{You can't use '\@backslashchar #1' in key macro within keylist}% + {Use '\@backslashchar #2' instead of '\@backslashchar #1'.}% +} +\SKV@def\SKV@define@multkeys#1,#2,#3,#4\@nil{% + \let\SKV@altlisterr\z@ + \SKV@trailead{#1}\SKV@tempa + \SKV@checkchoice{\SKV@tempa}{ord,cmd,bool,tog,choice,menu}{% + \edef\SKV@keytype{\the\numexpr\nr+1}% + }{% + \SKV@checkchoice{\SKV@tempa}{1,2,3,4,5}{% + \edef\SKV@keytype{\the\numexpr\nr+1}% + }{% + \SKV@err{Unknown key type/identifier '\string#1'}% + {Valid key types are 'ord', 'cmd', 'bool', 'tog', + 'choice', 'menu'\SKV@MB and '1', '2', '3', '4', '5'}% + }% + }% + \SKV@ifnotempty{#2}{}{% + \SKV@err{No key name specified for key type '\string#1'}% + {\string\define@keylist: key name required for all keys}% + }% \begingroup \SKV@ifblank{#4}{}{% - \def\SKV@tempa{\if,\fi,\fif}% - \SKV@detok@dsp\SKV@tempa - \def\SKV@tempb{#4}\SKV@detok@z@p\SKV@tempb - \@expandtwoargs\in@{\@nameuse{SKV@dsp1}}\SKV@tempb - \ifin@\SKV@afterfi\SKV@if@err\fi - \@expandtwoargs\in@{\@nameuse{SKV@dsp3}}\SKV@tempb + \edef\SKV@tempb{\detokenize{#4}\space}% + \edef\SKV@tempb{\expandafter\zap@space\SKV@tempb\@empty}% + \@expandtwoargs\SKV@in@\SKV@dsp@if\SKV@tempb \ifin@ - \SKV@afterelsefi - \SKV@namegdef{\SKV@keyprefix @\SKV@keyfamily @#2@func}{#4}% - \else - \SKV@afterfi - \SKV@namexdef{\SKV@keyprefix @\SKV@keyfamily @#2@func}{\SKV@expandox{#4}}% + \@expandtwoargs\SKV@in@\SKV@dsp@iftog\SKV@tempb + \ifin@\else + \@expandtwoargs\SKV@in@\SKV@dsp@ifswitch\SKV@tempb + \ifin@\else\SKV@noiferr{if}{skif}\fi + \fi \fi + \@expandtwoargs\SKV@in@\SKV@dsp@par\SKV@tempb + \ifin@\SKV@afterfi\SKV@noiferr{par}{endgraf}\fi + \@expandtwoargs\SKV@in@\SKV@dsp@ifcase\SKV@tempb + \ifin@\SKV@afterfi\SKV@noiferr{ifcase}{skifcase}\fi + \@expandtwoargs\SKV@in@\SKV@dsp@or\SKV@tempb + \ifin@\SKV@afterfi\SKV@noiferr{or}{skor}\fi + \@expandtwoargs\SKV@in@\SKV@dsp@else\SKV@tempb + \ifin@\SKV@afterfi\SKV@noiferr{else}{skelse}\fi }% \protected@edef\SKV@tempa{\endgroup - \ifcase#1\relax - \def\SKV@noc{\@ne}% + \ifcase\SKV@keytype\relax \or - \noexpand\SKV@def@key[\SKV@keyprefix]{\SKV@keyfamily}% - {#2}[#3]{% - \noexpand\SKV@nameuse{\SKV@keyprefix @\SKV@keyfamily @#2@func}% - }% + \noexpand\SKV@def@ordkey[\SKV@keyprefix]{\SKV@keyfamily}% + {#2}[#3]{\unexpanded{#4}}% \or \noexpand\SKV@def@cmdkey[\SKV@keyprefix]{\SKV@keyfamily}% - [\SKV@macroprefix]{#2}[#3]{% - \noexpand\SKV@nameuse{\SKV@keyprefix @\SKV@keyfamily @#2@func}% - }% + [\SKV@macroprefix]{#2}[#3]{\unexpanded{#4}}% \or \noexpand\SKV@def@boolkey+[\SKV@keyprefix]{\SKV@keyfamily}% - [\SKV@macroprefix]{#2}[#3]{% - \noexpand\SKV@nameuse{\SKV@keyprefix @\SKV@keyfamily @#2@func}% - }{% + [\SKV@macroprefix]{#2}[#3]{\unexpanded{#4}}{% \unexpanded{\SKV@inputerr{##1}{#2}}% }% \or \noexpand\SKV@def@togkey+[\SKV@keyprefix]{\SKV@keyfamily}% - [\SKV@macroprefix]{#2}[#3]{% - \noexpand\SKV@nameuse{\SKV@keyprefix @\SKV@keyfamily @#2@func}% - }{% + [\SKV@macroprefix]{#2}[#3]{\unexpanded{#4}}{% \unexpanded{\SKV@inputerr{##1}{#2}}% }% \or - \SKV@ifnameundef{\SKV@keyprefix @\SKV@keyfamily @#2@altlist}{% - \def\SKV@noa{\@ne}% - }{}% + \SKV@ifcsdef{\SKV@keyprefix @\SKV@keyfamily @#2@altlist}{}% + {\let\SKV@altlisterr\@ne}% \noexpand\SKV@def@choicekey*+[\SKV@keyprefix]{\SKV@keyfamily}{#2}% [\unexpanded{\val\nr}]{% - \SKV@nameuse{\SKV@keyprefix @\SKV@keyfamily @#2@altlist}% - }[#3]{% - \noexpand\SKV@nameuse{\SKV@keyprefix @\SKV@keyfamily @#2@func}% - }{% - \unexpanded{\SKV@inputerr{##1}{#2}}% - }% - \else - \def\SKV@noc{\@ne}% + \SKV@csuse{\SKV@keyprefix @\SKV@keyfamily @#2@altlist}% + }[#3]{\unexpanded{#4}}{\unexpanded{\SKV@inputerr{##1}{#2}}}% + \or + \SKV@ifcsdef{\SKV@keyprefix @\SKV@keyfamily @#2@altlist}{}% + {\let\SKV@altlisterr\@ne}% + \noexpand\SKV@def@choicekey*+[\SKV@keyprefix]{\SKV@keyfamily}{#2}% + [\unexpanded{\val\nr}]{% + \SKV@csuse{\SKV@keyprefix @\SKV@keyfamily @#2@altlist}% + }[#3]{\unexpanded{#4}}{\unexpanded{\SKV@inputerr{##1}{#2}}}% \fi }% \SKV@tempa - \ifnum\SKV@noa=\@ne + \ifnum\SKV@altlisterr=\@ne \SKV@afterfi \SKV@err{% - Choice key '#2' can't be defined.\MessageBreak + Choice key '#2' can't be defined.\SKV@MB Alternate key values list for '#2' is empty }{% - You need to first define admissible\MessageBreak - key values through '\string\ChoiceKeyValues'\MessageBreak + You need to first define admissible\SKV@MB + key values through '\string\choicekeyvalues'\SKV@MB for choice key '#2'. }% \fi - \ifnum\SKV@noc=\@ne - \SKV@afterfi - \SKV@err{Unknown key type/identifier '#1'}% - {You can only use key types 1 to 5.}% - \fi +} +\SKV@pdef*\SKV@in@#1#2{% + \def\in@@##1#1##2##3\in@@{\ifx\in@##2\in@false\else\in@true\fi}% + \in@@#2\@mil#1\in@\in@@ } \SKV@pdef*\in@tog#1#2{% - \def\in@@##1#1##2##3\in@@{% - \ifx\in@##2\togfalse{in@}\else\togtrue{in@}\fi - }% - \in@@#2#1\in@\in@@ + \SKV@in@{#1}{#2}% + \ifin@\togtrue{in@}\else\togfalse{in@}\fi } -\newtog{in@} +\deftog{in@} \SKV@pdef*\in@tok#1#2{% \begingroup - \edef\SKV@tempa{\detokenize{#1}}% - \edef\SKV@tempb{\detokenize{#2}}% - \SKV@expandargs{1}\KV@@sp@def\SKV@tempa\SKV@tempa\SKV@nil - \SKV@expandargs{1}\KV@@sp@def\SKV@tempb\SKV@tempb\SKV@nil - \SKV@expandargs{3}{\def\in@@##1}\SKV@tempa{% - ##2##3\in@@{\global\ifx\in@##2\in@false\else\in@true\fi}% - }\SKV@nil - \SKV@expandargs{3}\in@@{\SKV@tempb\SKV@tempa}{\in@\in@@}\SKV@nil + \SKV@expnext\SKV@trailead{\detokenize{#1}}\SKV@tempa + \SKV@expnext\SKV@trailead{\detokenize{#2}}\SKV@tempb + \@expandtwoargs\SKV@in@\SKV@tempa\SKV@tempb + \global\let\ifin@\ifin@ \endgroup } \def\XKV@makepf#1{% - \KV@@sp@def\XKV@prefix{#1}% - \SKV@expandargs{3}\XKV@checksanitizeb{{\SKV@rkpnames}}\SKV@tempa\SKV@nil - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \XKV@knftrue - \XKV@whilist\SKV@tempa\SKV@tempa\ifXKV@knf\fi{% - \ifx\XKV@prefix\SKV@tempa\XKV@knffalse\fi - }% - \unless\ifXKV@knf - \SKV@afterfi - \SKV@err{Prefix '\SKV@tempa' is not allowed}% - {Use another prefix instead of '\SKV@tempa'}% + \SKV@trailead{#1}\XKV@prefix + \ifSKV@sk\else + \SKV@expnext\XKV@checksanitizeb\SKV@rkpnames\SKV@tempa + \SKV@despacelist*\SKV@tempa + \XKV@knftrue + \XKV@whilist\SKV@tempa\SKV@tempa\ifXKV@knf\fi{% + \ifx\XKV@prefix\SKV@tempa\XKV@knffalse\fi + }% + \unless\ifXKV@knf + \SKV@afterfi + \SKV@err{Prefix '\SKV@tempa' is reserved}% + {Use another prefix name instead of '\SKV@tempa'.}% + \fi \fi \edef\SKV@pref{\ifx\XKV@prefix\@empty\else\XKV@prefix\fi}% \edef\XKV@prefix{\ifx\XKV@prefix\@empty\else\XKV@prefix @\fi}% } \def\XKV@makehd#1{% - \SKV@expandargs{1}\KV@@sp@def\XKV@header{#1}\SKV@nil - \SKV@expandargs{3}\XKV@checksanitizeb{{\SKV@rfnames}}\SKV@tempa\SKV@nil - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \XKV@knftrue - \XKV@whilist\SKV@tempa\SKV@tempa\ifXKV@knf\fi{% - \ifx\XKV@header\SKV@tempa\XKV@knffalse\fi - }% - \unless\ifXKV@knf - \SKV@afterfi - \SKV@err{Family '\SKV@tempa' is not allowed}% - {Use another family instead of '\SKV@tempa'}% + \SKV@expargs{3}\SKV@trailead{{#1}}\XKV@header\@nil + \ifSKV@sk\else + \SKV@expnext\XKV@checksanitizeb\SKV@rfnames\SKV@tempa + \SKV@despacelist*\SKV@tempa + \XKV@knftrue + \XKV@whilist\SKV@tempa\SKV@tempa\ifXKV@knf\fi{% + \ifx\XKV@header\SKV@tempa\XKV@knffalse\fi + }% + \unless\ifXKV@knf + \SKV@afterfi + \SKV@err{Family '\SKV@tempa' is reserved}% + {Use another family name instead of '\SKV@tempa'.}% + \fi \fi \edef\XKV@header{% \XKV@prefix\ifx\XKV@header\@empty\else\XKV@header @\fi}% } +\SKV@def*\SKV@resolvekey#1#2\@nil#3{% + \def\SKV@resolve##1#2##2##3\@nil##4{% + \edef##4{\unexpanded{##2}}% + \ifx##4\@nnil + \edef##4{\unexpanded{##1}}% + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi + }% + \SKV@resolve#1#2{\@nil}\@nil#3% +} +\SKV@def*\SKV@addtouserval{% + \SKV@addtolist+{SKV@\XKV@header uservalue}\SKV@resa} +\SKV@def*\SKV@gaddtouserval{% + \SKV@addtolist+?{SKV@\XKV@header uservalue}\SKV@resa} +\SKV@def*\SKV@addtosave{\SKV@addtolist+{XKV@\XKV@header save}\SKV@resa} +\SKV@def*\SKV@gaddtosave{\begingroup + \edef\SKV@tempa{\endgroup + \SKV@addtolist+?{XKV@\XKV@header save}{\global{\SKV@resa}}}% + \SKV@tempa +} +\SKV@def*\SKV@findkeypointers#1{% + \SKV@resolvekey{#1}\uservalue\savevalue\@nil\SKV@resa + {% + \SKV@addtouserval\SKV@addtosave + }{% + \SKV@resolvekey{#1}\guservalue\savevalue\@nil\SKV@resa + {% + \SKV@gaddtouserval\SKV@addtosave + }{% + \SKV@resolvekey{#1}\savevalue\uservalue\@nil\SKV@resa + {% + \SKV@addtouserval\SKV@addtosave + }{% + \SKV@resolvekey{#1}\gsavevalue\uservalue\@nil\SKV@resa + {% + \SKV@addtouserval\SKV@gaddtosave + }{% + \SKV@resolvekey{#1}\guservalue\gsavevalue\@nil\SKV@resa + {% + \SKV@gaddtouserval\SKV@gaddtosave + }{% + \SKV@resolvekey{#1}\gsavevalue\guservalue\@nil\SKV@resa + {% + \SKV@gaddtouserval\SKV@gaddtosave + }{% + \SKV@resolvekey{#1}\uservalue\@nil\SKV@resa + {% + \SKV@addtouserval + }{% + \SKV@resolvekey{#1}\guservalue\@nil\SKV@resa + {% + \SKV@gaddtouserval + }{% + \SKV@resolvekey{#1}\savevalue\@nil\SKV@resa + {% + \SKV@addtosave + }{% + \SKV@resolvekey{#1}\gsavevalue\@nil\SKV@resa + {% + \SKV@gaddtosave + }{}% + }% + }% + }% + }% + }% + }% + }% + }% + }% +} \def\XKV@define@key#1{% - \SKV@reservedkey@err{#1}% - \SKV@suspendedkey@err{#1}% - \SKV@ifnextchar[{\XKV@d@fine@k@y{#1}}{\SKV@d@fine@k@y{#1}}% + \SKV@findkeypointers{#1}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa + \begingroup + \edef\SKV@tempa{\endgroup + \SKV@ifbrack{\noexpand\XKV@d@fine@key{\SKV@resa}}% + {\noexpand\SKV@d@fine@key{\SKV@resa}}% + }% + \SKV@tempa } -\def\XKV@d@fine@k@y#1[#2]#3{%! +\def\XKV@d@fine@key#1[#2]#3{% \XKV@define@default{#1}{#2}% - \SKV@namedef{\XKV@header#1}##1{#3}% + \@namedef{\XKV@header#1}##1{#3}% } -\def\SKV@d@fine@k@y#1#2{\SKV@namedef{\XKV@header#1}##1{#2}} +\def\SKV@d@fine@key#1#2{\@namedef{\XKV@header#1}##1{#2}} \def\XKV@define@cmdkey#1#2[#3]#4{% - \SKV@reservedkey@err{#2}% - \SKV@suspendedkey@err{#2}% - \ifXKV@st\XKV@define@default{#2}{#3}\fi - \edef\SKV@tempa{\noexpand\def\@nameuse{\XKV@header#2}####1}% - \edef\SKV@tempb{\noexpand\def\@nameuse{#1#2}\unexpanded{{##1}#4}}% - \expandafter\SKV@tempa\expandafter{\SKV@tempb}% - \SKV@undef\SKV@tempa\SKV@undef\SKV@tempb + \SKV@findkeypointers{#2}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + \SKV@csundef{#1\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa + \ifXKV@st + \SKV@afterfi + \SKV@expnext\XKV@define@default\SKV@resa{#3}% + \fi + \begingroup + \def\SKV@tempa{% + \expandafter\def\csname\XKV@header\SKV@resa\endcsname####1}% + \@threeexpafter\endgroup\expandafter\SKV@tempa\expandafter% + {\expandafter\def\csname#1\SKV@resa\endcsname{##1}#4}% } \def\XKV@define@choicekey#1{% - \SKV@reservedkey@err{#1}% - \SKV@suspendedkey@err{#1}% - \@testopt{\XKV@d@fine@choicekey{#1}}{}% + \SKV@findkeypointers{#1}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa + \begingroup + \edef\SKV@tempa{\endgroup + \SKV@testopt{\noexpand\XKV@d@fine@choicekey{\SKV@resa}}{}% + }% + \SKV@tempa } \def\XKV@define@boolkey#1#2[#3]{% - \SKV@reservedkey@err{#2}% - \SKV@suspendedkey@err{#2}% + \SKV@findkeypointers{#2}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + \SKV@csundef{#1\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa \ifXKV@pl - \SKV@afterelsefi\expandafter\XKV@d@f@ne@boolkey + \def\SKV@n@xt{\SKV@aftercs\XKV@d@f@ne@boolkey}% \else - \SKV@afterfi\expandafter\XKV@d@fine@boolkey + \def\SKV@n@xt{\SKV@aftercs\XKV@d@fine@boolkey}% \fi - \csname\XKV@header#2\endcsname{#2}{#1#2}{#3}% + \edef\SKV@tempa{{\XKV@header\SKV@resa}{\SKV@resa}{#1\SKV@resa}{#3}}% + \expandafter\SKV@n@xt\SKV@tempa +} +\def\XKV@d@fine@boolkeys#1#2#3{% + \SKV@findkeypointers{#1}% + \SKV@ifcsundef{\XKV@header\SKV@resa}{}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@resa' in family '\XKV@tfam' with\SKV@MB + prefix '\SKV@pref' redefined\on@line} + \SKV@csundef{\XKV@header\SKV@resa}% + \SKV@csundef{#2\SKV@resa}% + }% + \SKV@expnext\SKV@reservkey@err\SKV@resa + \SKV@expnext\SKV@suspkey@err\SKV@resa + \edef\SKV@tempa{% + \noexpand\XKV@d@f@ne@b@olkey\@nameuse{\XKV@header\SKV@resa}% + {\SKV@resa}{#2\SKV@resa}{#3}{{\noexpand\@nameuse{#2\SKV@resa + \noexpand\XKV@resa}}}% + }% + \SKV@tempa } \SKV@pdef*\reserve@keys{\@testopt\SKV@reserve@keys{KV}} \SKV@def*\SKV@reserve@keys[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@res@rve@keys\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@despacelist*\SKV@tempa + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@res@rve@keys\SKV@tempa{#2}{#3}% }% } \SKV@def*\SKV@res@rve@keys#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil + \SKV@despacelist*\XKV@fams \SKV@for@b\XKV@fams\XKV@tfam{% \XKV@makehd\XKV@tfam \SKV@res@rve@k@ys{#3}% @@ -1151,170 +2233,121 @@ } \SKV@def*\SKV@res@rve@k@ys#1{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@ifnamedef{\XKV@header\SKV@tempa}{% + \SKV@ifcsdef{\XKV@header\SKV@tempa}{% \SKV@err{% Key '\SKV@tempa' with prefix '\SKV@pref' in family - \MessageBreak '\XKV@tfam' is already defined + \SKV@MB '\XKV@tfam' is already defined }{% Key '\SKV@tempa' in family '\XKV@tfam' can't be reserved. - \MessageBreak You may wish to remove it before reserving it. - \MessageBreak In that case, you can use '\string\remove@keys'. + \SKV@MB You may wish to remove it before reserving it. + \SKV@MB In that case, you can use '\string\remove@keys'. }% }{% - \SKV@nameedef{\XKV@header\SKV@tempa}{% + \SKV@csedef{\XKV@header\SKV@tempa}{% \SKV@err{% - Key '\SKV@tempa' with prefix '\SKV@pref' in family '\XKV@tfam' - \MessageBreak was reserved\on@line + Key '\SKV@tempa' with prefix '\SKV@pref' in family + '\XKV@tfam'\SKV@MB was reserved\on@line }{% Unreserve '\SKV@tempa' before use. }% }% - \SKV@namedef{\XKV@header\SKV@tempa @reser}{}% + \@namedef{\XKV@header\SKV@tempa @reser}{}% }% }% } -\let\SKV@no\@empty -\SKV@pdef\SKV@aftergroup{% - \SKV@ifstar{\SKV@aft@rgroup\@firstofone}{\SKV@aft@rgroup\unexpanded}% -} -\SKV@def\SKV@aft@rgroup#1#2{% - \edef\SKV@no{\the\numexpr\SKV@no+1}% - \SKV@namexdef{SKV@aft@rgr@up\SKV@no}{% - \SKV@namegundef{SKV@aft@rgr@up\SKV@no}% - #1{#2}% - }% - \SKV@aftercsname\aftergroup{SKV@aft@rgr@up\SKV@no}% -} -\SKV@pdef\SKV@afterassignment{% - \SKV@ifstar{\SKV@aft@rassignment\@firstofone}% - {\SKV@aft@rassignment\unexpanded}% -} -\SKV@def\SKV@aft@rassignment#1#2{% - \begingroup - \edef\SKV@no{\the\numexpr\SKV@no+1}% - \SKV@namexdef{SKV@aft@rassignm@nt\SKV@no}{% - \SKV@namegundef{SKV@aft@rassignm@nt\SKV@no}% - #1{#2}% - }% - \expandafter\endgroup\expandafter\afterassignment - \csname SKV@aft@rassignm@nt\SKV@no\endcsname -} -\SKV@def*\SKV@reservedkey@err#1{% - \SKV@ifnamedef{\XKV@header#1@reser}{% - \let\next\SKV@err - }{% - \let\next\@gobbletwo - }% - \next{% - Key '#1' with prefix '\SKV@pref'\MessageBreak - is reserved in family '\XKV@tfam' - }{% - Unreserve '#1' before use. - }% +\SKV@def*\SKV@reservkey@err#1{% + \SKV@ifcsdef{\XKV@header#1@reser}\SKV@err\@gobbletwo + {Key '#1' with prefix '\SKV@pref'\SKV@MB + is reserved in family '\XKV@tfam'}{Unreserve '#1' before use.}% } \SKV@def*\ifkeyreserved{\@testopt\SKV@ifkeyreserved{KV}} \SKV@def*\SKV@ifkeyreserved[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \XKV@knftrue - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@ifkey@reserved\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@ifkey@reserved\SKV@tempa{#2}{#3}% }% - \ifXKV@knf - \expandafter\@secondoftwo - \else - \expandafter\@firstoftwo - \fi + \@nameuse{@\ifXKV@knf second\else first\fi oftwo}% } \SKV@def*\SKV@ifkey@reserved#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil - \KV@@sp@def\XKV@tkey{#3}% + \SKV@despacelist*\XKV@fams + \SKV@trailead{#3}\XKV@tkey \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{% \XKV@makehd\XKV@tfam - \SKV@ifnamedef{\XKV@header\XKV@tkey @reser}{\XKV@knffalse}{}% + \SKV@ifcsdef{\XKV@header\XKV@tkey @reser}{\XKV@knffalse}{}% }% } \SKV@def*\ifkeysuspended{\@testopt\SKV@ifkeysuspended{KV}} \SKV@def*\SKV@ifkeysuspended[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \XKV@knftrue - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@ifkey@suspended\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@ifkey@suspended\SKV@tempa{#2}{#3}% }% - \ifXKV@knf - \expandafter\@secondoftwo - \else - \expandafter\@firstoftwo - \fi + \@nameuse{@\ifXKV@knf second\else first\fi oftwo}% } \SKV@def*\SKV@ifkey@suspended#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil - \KV@@sp@def\XKV@tkey{#3}% + \SKV@despacelist*\XKV@fams + \SKV@trailead{#3}\XKV@tkey \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{% \XKV@makehd\XKV@tfam - \SKV@ifnamedef{\XKV@header\XKV@tkey @sus}{\XKV@knffalse}{}% + \SKV@ifcsdef{\XKV@header\XKV@tkey @susp}{\XKV@knffalse}{}% }% } \SKV@def*\ifkeydefined{\@testopt\SKV@ifkeydefined{KV}} \SKV@def*\SKV@ifkeydefined[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \XKV@knftrue - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@ifk@ydefined\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@ifk@ydefined\SKV@tempa{#2}{#3}% }% - \ifXKV@knf - \expandafter\@secondoftwo - \else - \expandafter\@firstoftwo - \fi + \@nameuse{@\ifXKV@knf second\else first\fi oftwo}% } \SKV@def*\SKV@ifk@ydefined#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil - \KV@@sp@def\XKV@tkey{#3}% + \SKV@despacelist*\XKV@fams + \SKV@trailead{#3}\XKV@tkey \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{% \XKV@makehd\XKV@tfam - \SKV@ifnamedef{\XKV@header\XKV@tkey}{\XKV@knffalse}{}% + \SKV@ifcsdef{\XKV@header\XKV@tkey}{\XKV@knffalse}{}% }% } \SKV@def*\SKV@disabledkey@err{% \SKV@err{% Key '\SKV@disabledkey' with prefix '\SKV@pref' in family - \MessageBreak '\XKV@tfam' was disabled\on@line + \SKV@MB '\XKV@tfam' was disabled\on@line }{% - You can't set or reset '\SKV@disabledkey' at this\MessageBreak - late stage. Perhaps you're required to set it \MessageBreak - earlier, in the document's preamble. + You can't set or reset '\SKV@disabledkey' at this\SKV@MB + late stage. Perhaps you're required to set it \SKV@MB + earlier, within a package or in the document's preamble. }% } -\protected\def\disable@keys{% +\def\disable@keys{% \SKV@ifstar{\@testopt\XKV@disable@keys{KV}}% {\@testopt\SKV@disable@keys{KV}}% } \SKV@def*\SKV@disable@keys[#1]#2#3{% + \SKV@locfalse \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@dis@ble@keys\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@despacelist*\SKV@tempa + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@dis@ble@keys\SKV@tempa{#2}{#3}% }% } \SKV@def*\SKV@dis@ble@keys#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil + \SKV@despacelist*\XKV@fams \SKV@for@b\XKV@fams\XKV@tfam{% \XKV@makehd\XKV@tfam \SKV@dis@ble@k@ys{#3}% @@ -1322,58 +2355,80 @@ } \SKV@def*\SKV@dis@ble@k@ys#1{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@ifnameundef{\XKV@header\SKV@tempa}{% - \SKV@warn{Key '\SKV@tempa' with prefix '\SKV@pref' - \MessageBreak is undefined in family '\XKV@tfam': - \MessageBreak can't be disabled\on@line}% + \SKV@ifcsundef{\XKV@header\SKV@tempa}{% + \ifSKV@verbose\SKV@disabledkey@warn\fi }{% \SKV@dis@ble@k@y@\SKV@tempa }% }% } +\def\SKV@disabledkey@warn{% + \SKV@warn{Key '\SKV@tempa' with prefix '\SKV@pref' + \SKV@MB is undefined in family '\XKV@tfam': + \SKV@MB can't be \ifSKV@loc localized + \else disabled\fi\on@line + }% +} +\def\SKV@disabledkey@info{% + \SKV@info{Key '\SKV@disabledkey' with prefix '\SKV@pref' + in family '\XKV@tfam'\SKV@MB was \ifSKV@loc localized + \else disabled\fi\on@line + }% +} \SKV@def*\SKV@dis@ble@k@y@#1{% \edef\SKV@disabledkey{#1}% - \SKV@ifnameundef{\XKV@header#1@default}{% + \SKV@ifcsundef{\XKV@header#1@default}{% \edef#1{\noexpand\XKV@define@key{#1}}% }{% \edef#1{\noexpand\XKV@define@key{#1}[]}% }% - \SKV@expandargs{0}#1\SKV@disabledkey@err\SKV@nil - \SKV@info{Key '\SKV@disabledkey' with prefix '\SKV@pref' in family '\XKV@tfam' - \MessageBreak was disabled\on@line}% + \SKV@expargs{0}#1\SKV@disabledkey@err\@nil + \ifSKV@verbose\SKV@disabledkey@info\fi } -\SKV@def*\SKV@suspendedkey@err#1{% - \SKV@ifnamedef{\XKV@header#1@sus}{% - \SKV@err{% - Key '#1' was suspended from family '\XKV@tfam' - }{% - You can use \string\restore@key\space to restore '#1'. - }% - }{}% +\SKV@pdef*\localize@keys{% + \SKV@onlypackage\SKV@savstate + \SKV@t@stopta{\@testopt\SKV@localize@keys{KV}}% } -\SKV@def*\SKV@suspendedkey@e@r{% - \SKV@err{% - Key '\SKV@suspendedkey' in family '\XKV@tfam' was - \MessageBreak suspended\on@line - }{% - You can use \string\restore@key\space to restore '\SKV@suspendedkey'. +\SKV@def*\SKV@localize@keys[#1]#2#3{% + \SKV@loctrue + \ifSKV@st + \expandafter\SKV@BeforeDocumentStart + \else + \expandafter\SKV@AfterPackageEnd + \fi + {% + \XKV@checksanitizeb{#1}\SKV@tempa + \SKV@despacelist*\SKV@tempa + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@dis@ble@keys\SKV@tempa{#2}{#3}% + }% }% + \SKV@resstate +} +\SKV@def*\SKV@suspkey@err#1{% + \SKV@ifcsdef{\XKV@header#1@susp}\SKV@err\@gobbletwo + {Key '#1' was suspended from family '\XKV@tfam'}% + {You can use \string\restore@key\space to restore '#1'.}% +} +\SKV@def*\SKV@suspkey@e@r{% + \SKV@err{Key '\SKV@suspkey' in family '\XKV@tfam' was\SKV@MB + suspended\on@line}{You can use \string\restore@key\space + to restore '\SKV@suspkey'.}% } \SKV@pdef*\suspend@keys{\@testopt\SKV@suspend@keys{KV}} \SKV@def*\SKV@suspend@keys[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@s@spend@keys\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@despacelist*\SKV@tempa + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@s@spend@keys\SKV@tempa{#2}{#3}% }% } \SKV@def*\SKV@s@spend@keys#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil + \SKV@despacelist*\XKV@fams \SKV@for@b\XKV@fams\XKV@tfam{% \XKV@makehd\XKV@tfam \SKV@s@sp@nd@keys{#3}% @@ -1381,45 +2436,46 @@ } \SKV@def*\SKV@s@sp@nd@keys#1{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@ifnameundef{\XKV@header\SKV@tempa}{% - \SKV@warn{Key '\SKV@tempa' with prefix '\SKV@pref' - \MessageBreak is undefined in family '\XKV@tfam': - \MessageBreak can't be suspended\on@line}% + \SKV@ifcsundef{\XKV@header\SKV@tempa}{% + \SKV@vbsmsg{warn}{% + Key '\SKV@tempa' with prefix '\SKV@pref' + \SKV@MB is undefined in family '\XKV@tfam': + \SKV@MB can't be suspended\on@line}% }{% \SKV@s@sp@nd@k@ys\SKV@tempa }% }% } \SKV@def*\SKV@s@sp@nd@k@ys#1{% - \SKV@ifnamedef{\XKV@header#1@sus}{% + \SKV@ifcsdef{\XKV@header#1@susp}{% \SKV@err{% - Key '#1' with prefix '\SKV@pref' was suspended from family '\XKV@tfam' + Key '#1' with prefix '\SKV@pref' + was suspended from family '\XKV@tfam' }{% You can use \string\restore@key\space to restore '#1'. }% }{% - \edef\SKV@suspendedkey{#1}% - \global\nameletname{\XKV@header#1@sus}{\XKV@header#1}% - \SKV@nameedef{\XKV@header#1}{\SKV@suspendedkey@e@r}% - \SKV@info{Key '\SKV@suspendedkey' with prefix '\SKV@pref' in - \MessageBreak family '\XKV@tfam' was suspended\on@line}% + \edef\SKV@suspkey{#1}% + \global\SKV@csletcs{\XKV@header#1@susp}{\XKV@header#1}% + \SKV@csedef{\XKV@header#1}{\SKV@suspkey@e@r}% + \SKV@vbsmsg{info}{Key '\SKV@suspkey' with prefix '\SKV@pref' in + \SKV@MB family '\XKV@tfam' was suspended\on@line}% }% } \SKV@pdef*\restore@keys{\@testopt\SKV@restore@keys{KV}} \SKV@def*\SKV@restore@keys[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@r@store@keys\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@despacelist*\SKV@tempa + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@r@store@keys\SKV@tempa{#2}{#3}% }% } \SKV@def*\SKV@r@store@keys#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil + \SKV@despacelist*\XKV@fams \SKV@for@b\XKV@fams\XKV@tfam{% \XKV@makehd\XKV@tfam \SKV@r@st@re@keys{#3}% @@ -1427,42 +2483,42 @@ } \SKV@def*\SKV@r@st@re@keys#1{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@ifnameundef{\XKV@header\SKV@tempa}{% - \SKV@warn{Key '\SKV@tempa' with prefix '\SKV@pref' - \MessageBreak is undefined in family '\XKV@tfam': - \MessageBreak can't be restored\on@line}% + \SKV@ifcsundef{\XKV@header\SKV@tempa}{% + \SKV@vbsmsg{warn}{Key '\SKV@tempa' with prefix '\SKV@pref' + \SKV@MB is undefined in family '\XKV@tfam': + \SKV@MB can't be restored\on@line}% }{% \SKV@r@st@re@k@ys\SKV@tempa }% }% } \SKV@def*\SKV@r@st@re@k@ys#1{% - \SKV@ifnameundef{\XKV@header#1@sus}{% + \SKV@ifcsundef{\XKV@header#1@susp}{% \SKV@err{Key '#1' wasn't suspended from family - \MessageBreak '\XKV@tfam': can't be restored\on@line}\@ehc + \SKV@MB '\XKV@tfam': can't be restored\on@line}% + {I can't restore unsuspended key '#1'}% }{% \edef\SKV@restoredkey{#1}% - \nameletname{\XKV@header#1}{\XKV@header#1@sus}% - \SKV@nameundef{\XKV@header#1@sus}% - \SKV@info{Key '\SKV@restoredkey' with prefix '\SKV@pref' in family - \MessageBreak '\XKV@tfam' restored\on@line}% + \SKV@csletcs{\XKV@header#1}{\XKV@header#1@susp}% + \SKV@csundef{\XKV@header#1@susp}% + \SKV@vbsmsg{info}{Key '\SKV@restoredkey' with prefix + '\SKV@pref' in family \SKV@MB '\XKV@tfam' restored\on@line}% }% } \SKV@pdef*\remove@keys{\@testopt\SKV@remove@keys{KV}} \SKV@def*\SKV@remove@keys[#1]#2#3{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil - \SKV@CommandGenParser{,}% - \SKV@for@b\SKV@tempa\SKV@tempa{% - \expandafter\SKV@r@move@keys\expandafter{\SKV@tempa}{#2}{#3}% + \SKV@despacelist*\SKV@tempa + \SKV@for*[,]\SKV@tempa\SKV@tempa{% + \SKV@expnext\SKV@r@move@keys\SKV@tempa{#2}{#3}% }% } \SKV@def*\SKV@r@move@keys#1#2#3{% \XKV@makepf{#1}% \XKV@checksanitizeb{#2}\XKV@fams - \SKV@expandargs{1}\XKV@sp@deflist\XKV@fams\XKV@fams\SKV@nil + \SKV@despacelist*\XKV@fams \SKV@for@b\XKV@fams\XKV@tfam{% \XKV@makehd\XKV@tfam \SKV@r@m@ve@keys{#3}% @@ -1470,12 +2526,20 @@ } \SKV@def*\SKV@r@m@ve@keys#1{% \XKV@checksanitizeb{#1}\SKV@tempa - \SKV@expandargs{1}\XKV@sp@deflist\SKV@tempa\SKV@tempa\SKV@nil + \SKV@despacelist*\SKV@tempa \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@ifnameundef{\XKV@header\SKV@tempa}{% - \SKV@warn{Key '\SKV@tempa' with prefix '\SKV@pref' - \MessageBreak is undefined in family '\XKV@tfam': - \MessageBreak I can't remove or unreserve it\on@line}% + \SKV@ifcsundef{\XKV@header\SKV@tempa @susp}{}{% + \SKV@err{Key '\SKV@tempa' with prefix '\SKV@pref' + \SKV@MB was suspended from family '\XKV@tfam': + \SKV@MB I can't remove/unreserve it\on@line. + \SKV@MB You need to first restore key '\SKV@tempa' + \SKV@MB before you can remove/unreserve it}% + {First restore key '\SKV@tempa' before removing it.}% + }% + \SKV@ifcsundef{\XKV@header\SKV@tempa}{% + \SKV@vbsmsg{warn}{Key '\SKV@tempa' with prefix '\SKV@pref' + \SKV@MB is undefined in family '\XKV@tfam': + \SKV@MB I can't remove or unreserve it\on@line}% }{% \SKV@r@m@ve@k@ys\SKV@tempa }% @@ -1484,28 +2548,39 @@ \SKV@def*\SKV@r@m@ve@k@ys#1{% \begingroup \edef\SKV@tempa{\XKV@header#1,\XKV@header#1@default, - \XKV@header#1@func,%\XKV@header#1@value, - \XKV@header#1@altlist,\XKV@header#1@reser + \XKV@header#1@func,\XKV@header#1@altlist, + \XKV@header#1@reser }% \SKV@for@b\SKV@tempa\SKV@tempa{% - \SKV@expandargs{1}\KV@@sp@def\SKV@tempa\SKV@tempa\SKV@nil - \SKV@namegundef{\SKV@tempa}% + \SKV@despace\SKV@tempa + \SKV@csgundef{\SKV@tempa}% }% \endgroup - \SKV@info{Key '#1' with prefix '\SKV@pref' in family '\XKV@tfam' - \MessageBreak was removed\on@line}% + \SKV@vbsmsg{info}{Key '#1' with prefix '\SKV@pref' in family\SKV@MB + '\XKV@tfam' was removed\on@line}% } \SKV@newlet\unreserve@keys\remove@keys +\SKV@def*\uservaluekeys{\XKV@testoptb\SKV@uservaluekeys} +\SKV@def*\SKV@uservaluekeys#1{% + \SKV@ifcsundef{SKV@\XKV@header uservalue}{% + \XKV@checksanitizeb{#1}\SKV@tempa + \SKV@csxdef{SKV@\XKV@header uservalue}{\SKV@expox{\SKV@tempa}}% + }{% + \SKV@aftercs\XKV@merge{SKV@\XKV@header uservalue}{#1}\XKV@getsg + }% +} \def\setkeys{% - \def\fif##1{% - \SKV@findescape{##1}{% - \SKV@err{Bad argument '\string##1'}% - {Backslash in '\string##1' not allowed.}% - }{}% + \def\skif##1{% + \SKV@ensurenoscape{##1}% + \SKV@ifcsdef{if##1}{}{% + \SKV@err{Undefined boolean '##1'}% + {Boolean '##1' undefined: This is an '\string\skif' error.}% + }% \csname if##1\endcsname }% - \let\ffi\fi - \XKV@testopta{\XKV@testoptc\XKV@setkeys}% + \let\skifx\ifx\let\skifcase\ifcase\let\skor\or + \let\skelse\else\let\skfi\fi + \SKV@sktrue\XKV@testopta{\XKV@testoptc\XKV@setkeys}% } \def\XKV@setkeys[#1]#2{% \XKV@checksanitizea{#2}\XKV@resb @@ -1517,163 +2592,247 @@ }% \ifnum\XKV@depth=\z@\let\XKV@rm\@empty\fi \XKV@usepresetkeys{#1}{preseth}% - \expandafter\XKV@s@tkeys\expandafter{\XKV@resb}{#1}% + \SKV@expnext\XKV@s@tkeys\XKV@resb{#1}% \XKV@usepresetkeys{#1}{presett}% \let\CurrentOption\@empty + \SKV@skfalse +} +\def\XKV@s@tk@ys@#1{% + \SKV@ifcsundef{\XKV@header\XKV@tkey}{% + \SKV@vbsmsg{warn}{No key macro for key '\XKV@tkey'}% + }{% + \XKV@knffalse + \SKV@ifcsundef{SKV@\XKV@header uservalue}{}{% + \SKV@aftercs\SKV@testuservaluekey + {SKV@\XKV@header uservalue}\XKV@tkey + \ifSKV@uv + \SKV@ifnotblank{#1}{}{% + \SKV@err{You're required to supply a value\SKV@MB + for key '\XKV@tkey'}% + {Supply a value for key '\XKV@tkey' before continuing.}% + }% + \fi + }% + \SKV@ifcsundef{XKV@\XKV@header save}{}{% + \SKV@aftercs\XKV@testsavekey{XKV@\XKV@header save}\XKV@tkey + }% + \ifXKV@rkv + \ifXKV@sg\expandafter\global\fi + \SKV@aftercs\let{XKV@\XKV@header\XKV@tkey @value}\XKV@tempa + \fi + \SKV@expnext\XKV@replacepointers\XKV@tempa + \SKV@ifblank{#1}{% + \SKV@ifcsundef{\XKV@header\XKV@tkey @default}{% + \SKV@err{'\XKV@tkey' in family '\XKV@tfam' with\SKV@MB + prefix '\XKV@pref' has no default value and\SKV@MB + you haven't supplied a value for it either}% + {Supply a value for key '\XKV@tkey' and rerun.}% + }{% + \SKV@xaftercs\XKV@default{\XKV@header\XKV@tkey @default}\@nil + }% + }{% + \XKV@savstate + \csname\XKV@header\XKV@tkey\expandafter + \endcsname\expandafter{\XKV@tempa}\relax + \XKV@resstate + }% + }% +} +\SKV@def*\SKV@testuservaluekey#1#2{% + \let\SKV@st@aux\ifSKV@st\SKV@sttrue\SKV@uvfalse + \XKV@whilist#1\SKV@tempa\ifSKV@st\fi{% + \ifx#2\SKV@tempa\SKV@uvtrue\SKV@stfalse\fi + }% + \let\ifSKV@st\SKV@st@aux\SKV@relax\SKV@st@aux } \SKV@def*\SKV@remspaceletter#1#2{% \begingroup - \XKV@toks\expandafter{#2 #1}% - \def\SKV@tempa##1 #1##2\SKV@nil{% + \SKV@toks\expandafter{#2 #1}% + \def\SKV@tempa##1 #1##2\@nil{% \SKV@ifblank{##2}{% - \XKV@toks{##1}% + \SKV@toks{##1}% }{% - \XKV@toks{##1#1##2}% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil + \SKV@toks{##1#1##2}% + \expandafter\SKV@tempa\the\SKV@toks\@nil }% }% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil - \xdef#2{\the\XKV@toks}% + \expandafter\SKV@tempa\the\SKV@toks\@nil + \xdef#2{\the\SKV@toks}% \endgroup } \SKV@def*\SKV@remletterspace#1#2{% \begingroup - \XKV@toks\expandafter{#2#1 }% - \def\SKV@tempa##1#1 ##2\SKV@nil{% + \SKV@toks\expandafter{#2#1 }% + \def\SKV@tempa##1#1 ##2\@nil{% \SKV@ifblank{##2}{% - \XKV@toks{##1}% + \SKV@toks{##1}% }{% - \XKV@toks{##1#1##2}% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil + \SKV@toks{##1#1##2}% + \expandafter\SKV@tempa\the\SKV@toks\@nil }% }% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil - \xdef#2{\the\XKV@toks}% + \expandafter\SKV@tempa\the\SKV@toks\@nil + \xdef#2{\the\SKV@toks}% \endgroup } \SKV@def*\SKV@remletterletter#1#2{% \begingroup - \XKV@toks\expandafter{#2#1#1}% - \def\SKV@tempa##1#1#1##2\SKV@nil{% - \XKV@toks{##1#1##2}% - \SKV@ifblank{##2}{}{\expandafter\SKV@tempa\the\XKV@toks\SKV@nil}% - }% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil - \def\SKV@tempa##1#1#1\SKV@nil{\gdef#2{##1}}% - \expandafter\SKV@tempa\the\XKV@toks#1\SKV@nil + \SKV@toks\expandafter{#2#1#1}% + \def\SKV@tempa##1#1#1##2\@nil{% + \SKV@toks{##1#1##2}% + \SKV@ifblank{##2}{}{% + \expandafter\SKV@tempa\the\SKV@toks\@nil}% + }% + \expandafter\SKV@tempa\the\SKV@toks\@nil + \def\SKV@tempa##1#1#1\@nil{\gdef#2{##1}}% + \expandafter\SKV@tempa\the\SKV@toks#1\@nil \endgroup } -\def\SKV@remcommaequal#1#2{% +\SKV@def*\SKV@remcommaequal#1#2{% \begingroup - \XKV@toks\expandafter{#2#1}% - \def\SKV@tempa##1#1##2\SKV@nil{% + \SKV@toks\expandafter{#2#1}% + \def\SKV@tempa##1#1##2\@nil{% \SKV@ifblank{##2}{% - \XKV@toks{##1}% + \SKV@toks{##1}% }{% - \XKV@toks{##1=##2}% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil + \SKV@toks{##1=##2}% + \expandafter\SKV@tempa\the\SKV@toks\@nil }% }% - \expandafter\SKV@tempa\the\XKV@toks\SKV@nil - \xdef#2{\the\XKV@toks}% + \expandafter\SKV@tempa\the\SKV@toks\@nil + \xdef#2{\the\SKV@toks}% \endgroup } \SKV@def*\SKV@normalizea#1{% - \@expandtwoargs\in@{ ,}{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{ ,}{\SKV@expox{#1}}% \ifin@\SKV@remspaceletter{,}#1\fi - \@expandtwoargs\in@{, }{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{, }{\SKV@expox{#1}}% \ifin@\SKV@remletterspace{,}#1\fi - \@expandtwoargs\in@{,,}{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{,,}{\SKV@expox{#1}}% \ifin@\SKV@remletterletter{,}#1\fi - \@expandtwoargs\in@{ =}{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{ =}{\SKV@expox{#1}}% \ifin@\SKV@remspaceletter{=}#1\fi - \@expandtwoargs\in@{= }{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{= }{\SKV@expox{#1}}% \ifin@\SKV@remletterspace{=}#1\fi - \@expandtwoargs\in@{==}{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{==}{\SKV@expox{#1}}% \ifin@\SKV@remletterletter{=}#1\fi - \@expandtwoargs\in@{,=}{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{,=}{\SKV@expox{#1}}% \ifin@\SKV@remcommaequal{,=}#1\fi - \@expandtwoargs\in@{=,}{\SKV@expandox{#1}}% + \@expandtwoargs\SKV@in@{=,}{\SKV@expox{#1}}% \ifin@\SKV@remcommaequal{=,}#1\fi } -\SKV@pdef\AtStartOfDocument{\AtBeginDocument} -\SKV@pdef\BeforeStartOfDocument{\SKV@gapptomacro@a\SKV@beforestartdocument} -\SKV@def*\SKV@beforestartdocument{} -\SKV@preptomacro@a\document{% - \endgroup - \let\BeforeStartOfDocument\@firstofone - \SKV@beforestartdocument - \protected\long\def\BeforeStartOfDocument{\expandafter\@notprerr\@gobble}% - \SKV@undef\SKV@beforestartdocument - \begingroup -} -\SKV@pdef\AfterStartOfDocument{\SKV@gapptomacro@a\SKV@afterstartdocument} -\SKV@def*\SKV@afterstartdocument{} -\SKV@apptomacro@a\document{% - \let\AfterStartOfDocument\@firstofone - \SKV@afterstartdocument - \protected\long\def\AfterStartOfDocument{\expandafter\@notprerr\@gobble}% - \SKV@undef\SKV@afterstartdocument\ignorespaces -} \SKV@def*\SKV@gobblescape{% \ifnum\escapechar>255\else \ifnum\escapechar<0\else - \expandafter\expandafter\csname @gobble\ifnum\escapechar=32 space\fi - \expandafter\expandafter\expandafter\endcsname + \expandafter\expandafter + \csname @gobble\ifnum\escapechar=32 space\fi + \@threeexpafter\endcsname \fi\fi - \string + \string% } \SKV@def*\SKV@save#1{% - \SKV@findescape{#1}{}{\SKV@err{'#1' not a control sequence}\@ehc} - \SKV@ifnamedef{Saved\SKV@gobblescape#1}{% + \SKV@ensurescape{#1}% + \edef\SKV@tempa{saved\SKV@gobblescape#1}% + \SKV@ifcsdef\SKV@tempa{% \SKV@err{% - \string#1\space already saved. You've to restore\MessageBreak - it or undefine \SKV@noexpandcs{Saved\SKV@gobblescape#1}% - before\MessageBreak you can save \string#1\space again + \string#1\space already saved. You've to restore\SKV@MB + it or undefine '\SKV@expcsox{\SKV@tempa}' before\SKV@MB + you can save \string#1\space again }\@ehc }{% - \nameletcs{Saved\SKV@gobblescape#1}{#1}% + \SKV@ifdef{#1}{% + \SKV@cslet\SKV@tempa{#1}% + }{% + \SKV@err{Undefined '\string#1' can't be saved\on@line}% + {You can't restore undefined commands.\SKV@MB + So why save undefined '\string#1' here?}% + }% }% } \SKV@def*\SKV@restore#1{% - \SKV@findescape{#1}{}{\SKV@err{'#1' not a control sequence}\@ehc} - \SKV@ifnamedef{Saved\SKV@gobblescape#1}{% - \csletname{#1}{Saved\SKV@gobblescape#1}% - \SKV@nameundef{Saved\SKV@gobblescape#1}% + \SKV@ensurescape{#1}% + \edef\SKV@tempa{saved\SKV@gobblescape#1}% + \SKV@ifcsdef\SKV@tempa{% + \def\SKV@n@xt{\SKV@letcs#1\SKV@tempa\SKV@csundef\SKV@tempa}% }{% - \SKV@warn{% - \@nameuse{Saved\SKV@gobblescape#1} undefined: can't be restored\on@line. - \MessageBreak Note that each call of \string\SKV@restore\space undefines - \MessageBreak the saved command + \SKV@err{% + '\@nameuse\SKV@tempa' is undefined:\SKV@MB + '\string#1' can't be restored\on@line + }{% + '\string#1' can't be restored\on@line.\SKV@MB + Note that each call to \string\SKV@restore\space + undefines\SKV@MB the saved command. }% }% + \SKV@n@xt } -\providecommand*\input@path{} +\SKV@providedef*\input@path{} \SKV@pdef*\InputFileOnce{% - \edef\SKV@no{\z@}\SKV@save\input@path - \SKV@testopt\SKV@InputFileOnce{.}% + \def\SKV@inputfile##1##2{% + \InputIfFileExists{##2}{% + \SKV@aftercs\let{##2@read}\@empty + \let\SKV@inp@tfile\relax + }{% + \typein[\Answer]{^^J! File '\string##2' does not exist.^^J + Enter filename or 'no' and <return> to continue.}% + \SKV@oifstrequal{\Answer}{no}{% + \let\SKV@inp@tfile\relax + }{% + \def\SKV@inp@tfile{% + \SKV@expargs{0}{\SKV@InputFileOnce[##1]}\Answer\@nil + }% + }% + }% + }% + \let\SKV@no\z@ + \SKV@save\input@path + \SKV@t@stopta{\SKV@testopt\SKV@InputFileOnce{.}}% } \SKV@def*\SKV@InputFileOnce[#1]#2{% - \SKV@gapptomacro@a\input@path{{#1/}}% - \if X\SKV@nameuse{#2@read}\relax - \ifSKV@inputonce - \SKV@afterelsefi - \SKV@err{! File '#2' already read}{File '#2' can't be read again.}% - \fi + \gapptomac\input@path{{#1/}}% + \ifSKV@st + \SKV@afterelsefi + \SKV@inputfile{#1}{#2}% \else - \SKV@namegdef{#2@read}{X}% - \InputIfFileExists{#2}{}{% - \typein[\Answer]{^^J! File '\string#2' does not exist.^^J - Enter filename or 'n' and <return> to continue.}% - \if n\Answer\relax\else - \SKV@expandargs{0}{\SKV@InputFileOnce[#1]}\Answer\SKV@nil - \fi + \SKV@afterfi + \SKV@ifcsdef{#2@read}{% + \SKV@vbsmsg{warn}{File '#2' already read:\SKV@MB + File '#2' can't be read again}% + }{% + \SKV@inputfile{#1}{#2}% }% \fi + \SKV@inp@tfile \ifnum\SKV@no=\z@\SKV@restore\input@path\fi - \edef\SKV@no{\@ne}% + \let\SKV@no\@ne +} +\SKV@pdef\SKV@notloaded@err#1{% + \SKV@ifcsdef{ver@#1.\@pkgextension}{}{% + \SKV@err{Package '#1' wasn't loaded}% + {Document has started and package '#1' wasn't loaded.}% + }% +} +\SKV@def*\SKV@notloaded{} +\SKV@pdef*\@ensurepackageloaded#1{% + \SKV@for[,]{#1}\SKV@resvd{% + \expandafter\gapptomac\expandafter\SKV@notloaded + \expandafter{\expandafter\SKV@do@b\expandafter{\SKV@resvd}}% + }% +} +\SKV@AtDocumentStart{% + \let\SKV@do@b\SKV@notloaded@err + \SKV@notloaded + \global\let\SKV@do@b\@gobble +} +\SKV@onlypreamble{% + \SKV@preamblecmds\SKV@onlypreamble + \@afterpackageloaded\@ifpackagecurrent\@ifpackagenotcurrent + \SKV@notloaded\@ensurepackageloaded\SKV@AtPackageEnd + \SKV@AtClassEnd\SKV@BeforePackageEnd\SKV@BeforeClassEnd + \SKV@AfterPackageEnd\SKV@AfterClassEnd\SKV@BeforeLastPage + \SKV@AfterLastPage\SKV@AfterDocumentEnd } \endinput -%%% End of file skeyval.sty %%%
\ No newline at end of file +%%% End of file skeyval.sty %%% |