diff options
author | Karl Berry <karl@freefriends.org> | 2020-07-13 21:10:18 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-07-13 21:10:18 +0000 |
commit | ef73787cfd526899301624dd2dc857195c1f6cfa (patch) | |
tree | 94ae45b1cdb21aa8b33fc3141a7d6462777a6fc1 /Master/texmf-dist/tex/generic | |
parent | 1f17cf107fbe98a4f0e280b82af0768266bc3446 (diff) |
expkv-def (13jul20)
git-svn-id: svn://tug.org/texlive/trunk@55829 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
-rw-r--r-- | Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex | 449 |
1 files changed, 328 insertions, 121 deletions
diff --git a/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex b/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex index d0f61214e56..9d504637338 100644 --- a/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex +++ b/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex @@ -35,8 +35,8 @@ \else \expandafter\endinput \fi -\def\ekvdVersion{0.4} -\def\ekvdDate{2020-07-04} +\def\ekvdVersion{0.5} +\def\ekvdDate{2020-07-12} \csname ekvd@tmp\endcsname \expandafter\chardef\csname ekvd@tmp\endcsname=\catcode`\@ \catcode`\@=11 @@ -45,8 +45,14 @@ {% \let\ekvd@long\ekvd@empty \let\ekvd@prot\ekvd@empty + \let\ekvd@ifalso\@secondoftwo } \ekvd@clear@prefixes +\long\def\ekvd@exp@Nno#1#2#3% + {% + \expandafter\ekvd@exp@reinsert@n\expandafter{#3}{#1{#2}}% + } +\long\def\ekvd@exp@reinsert@n#1#2{#2{#1}} \protected\def\ekvdefinekeys#1% {% \def\ekvd@set{#1}% @@ -56,9 +62,10 @@ \protected\long\def\ekvd@#1#2% {% \ekvd@clear@prefixes + \edef\ekvd@cur{\detokenize{#1}}% \ekvd@ifspace{#1}% {\ekvd@prefix\ekv@mark#1\ekv@stop{#2}}% - {\ekvd@err@missing@prefix{#1}}% + \ekvd@err@missing@type } \protected\def\ekvd@prefix#1 {\ekv@strip{#1}\ekvd@prefix@\ekv@mark} \protected\def\ekvd@prefix@#1#2\ekv@stop @@ -67,7 +74,7 @@ {\ekv@strip{#2}{\csname ekvd@t@#1\endcsname}}% {% \ekv@ifdefined{ekvd@p@#1}% - {\csname ekvd@p@#1\endcsname{#2}}% + {\csname ekvd@p@#1\endcsname\ekvd@prefix@after@p{#2}}% {\ekvd@err@undefined@prefix{#1}\@gobble}% }% } @@ -75,60 +82,73 @@ {% \ekvd@ifspace{#1}% {\ekvd@prefix#1\ekv@stop}% - {% - \expandafter\ekvd@err@missing@prefix\expandafter{\ekv@gobble@mark#1}% - \@gobble - }% + {\ekvd@err@missing@type\@gobble}% } -\protected\def\ekvd@p@long{\let\ekvd@long\long\ekvd@prefix@after@p} -\protected\def\ekvd@p@protected{\let\ekvd@prot\protected\ekvd@prefix@after@p} +\protected\def\ekvd@p@long{\let\ekvd@long\long} +\protected\def\ekvd@p@protected{\let\ekvd@prot\protected} \let\ekvd@p@protect\ekvd@p@protected +\protected\def\ekvd@p@also{\let\ekvd@ifalso\@firstoftwo} \protected\def\ekvd@t@set#1#2% {% - \ekvd@assert@not@long{set #1}% - \ekvd@assert@not@protected{set #1}% - \ekvd@ifnoarg{#2}% - {\ekvdefNoVal\ekvd@set{#1}{\ekvchangeset{#1}}}% + \ekvd@assert@not@long + \ekvd@assert@not@protected + \ekv@ifempty{#2}% + {\ekvd@err@missing@definition}% {% - \ekv@ifempty{#2}% - {\ekvd@err@missing@definition{set #1}}% - {\ekvdefNoVal\ekvd@set{#1}{\ekvchangeset{#2}}}% + \ekvd@ifalso + {% + \ekvd@ifnoarg{#2}% + {\ekvd@add@noval{#1}{\ekvchangeset{#1}}}% + {\ekvd@add@noval{#1}{\ekvchangeset{#2}}}% + \ekvd@assert@not@protected@also + }% + {% + \ekvd@ifnoarg{#2}% + {\ekvdefNoVal\ekvd@set{#1}{\ekvchangeset{#1}}}% + {\ekvdefNoVal\ekvd@set{#1}{\ekvchangeset{#2}}}% + }% }% } \protected\long\def\ekvd@type@noval#1#2#3#4% {% - \ekvd@assert@arg{#1noval #3}{#4}% + \ekvd@assert@arg{#4}% {% - \ekvd@assert@not@long{#1noval #3}% + \ekvd@assert@not@long \ekvd@prot#2\ekvd@tmp{#4}% - \ekvletNoVal\ekvd@set{#3}\ekvd@tmp + \ekvd@ifalso + {\ekvd@exp@Nno\ekvd@add@noval{#3}\ekvd@tmp{}}% + {\ekvletNoVal\ekvd@set{#3}\ekvd@tmp}% }% } \protected\def\ekvd@t@noval{\ekvd@type@noval{}\def} \protected\def\ekvd@t@enoval{\ekvd@type@noval e\edef} \protected\long\def\ekvd@type@code#1#2#3#4% {% - \ekvd@assert@arg{#1code #3}{#4} + \ekvd@assert@arg{#4} {% \ekvd@prot\ekvd@long#2\ekvd@tmp##1{#4}% - \ekvlet\ekvd@set{#3}\ekvd@tmp + \ekvd@ifalso + {\ekvd@exp@Nno\ekvd@add@val{#3}{\ekvd@tmp{##1}}{}}% + {\ekvlet\ekvd@set{#3}\ekvd@tmp}% }% } \protected\def\ekvd@t@code{\ekvd@type@code{}\def} \protected\def\ekvd@t@ecode{\ekvd@type@code e\edef} \protected\long\def\ekvd@type@default#1#2#3#4% {% - \ekvd@assert@arg{#1default #3}{#4}% + \ekvd@assert@arg{#4}% {% \ekvifdefined\ekvd@set{#3}% {% - \ekvd@assert@not@long{#1default #3}% + \ekvd@assert@not@long \ekvd@prot\edef\ekvd@tmp {% \unexpanded\expandafter#2% {\csname\ekv@name\ekvd@set{#3}\endcsname{#4}}% }% - \ekvletNoVal\ekvd@set{#3}\ekvd@tmp + \ekvd@ifalso + {\ekvd@exp@Nno\ekvd@add@noval{#3}\ekvd@tmp{}}% + {\ekvletNoVal\ekvd@set{#3}\ekvd@tmp}% }% {\ekvd@err@undefined@key{#3}}% }% @@ -137,26 +157,29 @@ \protected\def\ekvd@t@qdefault{\ekvd@type@default q{\expandafter\expandafter}} \protected\long\def\ekvd@t@edefault#1#2% {% - \ekvd@assert@arg{edefault #1}{#2}% + \ekvd@assert@arg{#2}% {% \ekvifdefined\ekvd@set{#1}% {% - \ekvd@assert@not@long{edefault #1}% + \ekvd@assert@not@long \ekvd@prot\edef\ekvd@tmp {\csname\ekv@name\ekvd@set{#1}\endcsname{#2}}% - \ekvletNoVal\ekvd@set{#1}\ekvd@tmp + \ekvd@ifalso + {\ekvd@exp@Nno\ekvd@add@noval{#1}\ekvd@tmp{}}% + {\ekvletNoVal\ekvd@set{#1}\ekvd@tmp}% }% {\ekvd@err@undefined@key{#1}}% }% } \long\def\ekvd@t@initial#1#2% {% - \ekvd@assert@arg{initial #1}{#2}% + \ekvd@assert@arg{#2}% {% \ekvifdefined\ekvd@set{#1}% {% - \ekvd@assert@not@long{initial #1}% - \ekvd@assert@not@protected{initial #1}% + \ekvd@assert@not@also + \ekvd@assert@not@long + \ekvd@assert@not@protected \csname\ekv@name\ekvd@set{#1}\endcsname{#2}% }% {\ekvd@err@undefined@key{#1}}% @@ -164,12 +187,13 @@ } \long\def\ekvd@t@oinitial#1#2% {% - \ekvd@assert@arg{oinitial #1}{#2}% + \ekvd@assert@arg{#2}% {% \ekvifdefined\ekvd@set{#1}% {% - \ekvd@assert@not@long{oinitial #1}% - \ekvd@assert@not@protected{oinitial #1}% + \ekvd@assert@not@also + \ekvd@assert@not@long + \ekvd@assert@not@protected \csname\ekv@name\ekvd@set{#1}\expandafter\endcsname\expandafter{#2}% }% {\ekvd@err@undefined@key{#1}}% @@ -177,12 +201,13 @@ } \long\def\ekvd@t@einitial#1#2% {% - \ekvd@assert@arg{einitial #1}{#2}% + \ekvd@assert@arg{#2}% {% \ekvifdefined\ekvd@set{#1}% {% - \ekvd@assert@not@long{einitial #1}% - \ekvd@assert@not@protected{einitial #1}% + \ekvd@assert@not@also + \ekvd@assert@not@long + \ekvd@assert@not@protected \edef\ekvd@tmp{#2}% \csname\ekv@name\ekvd@set{#1}\expandafter\endcsname\expandafter {\ekvd@tmp}% @@ -192,7 +217,7 @@ } \protected\def\ekvd@type@bool#1#2#3#4#5#6#7% {% - \ekvd@assert@filledarg{#1bool#2 #6}{#7}% + \ekvd@assert@filledarg{#7}% {% \ekvd@newlet#7#5% \ekvd@type@choice{#1bool#2}{#6}% @@ -210,59 +235,95 @@ \protected\def\ekvd@t@boolTF{\ekvd@type@bool{}{TF}{}\@firstoftwo\@secondoftwo} \protected\def\ekvd@t@gboolTF {\ekvd@type@bool g{TF}\global\@firstoftwo\@secondoftwo} -\protected\def\ekvd@type@data#1#2#3#4#5#6#7% +\protected\def\ekvd@type@data#1#2#3#4#5#6#7#8% {% - \ekvd@assert@filledarg{#1data#2 #6}{#7}% + \ekvd@assert@filledarg{#8}% {% - \ekvd@newlet#7#3% - \protected\ekvd@long\ekvdef\ekvd@set{#6}{\long#4#7####1#5{####1{##1}}}% + \ekvd@newlet#8#3% + \ekvd@ifalso + {% + \let\ekvd@prot\protected + \ekvd@add@val{#7}{\long#4#8####1#5{####1{#6}}}{}% + }% + {% + \protected\ekvd@long\ekvdef\ekvd@set{#7}% + {\long#4#8####1#5{####1{#6}}}% + }% }% } -\protected\def\ekvd@t@data{\ekvd@type@data{}{}\@secondoftwo\def{####2}} -\protected\def\ekvd@t@edata{\ekvd@type@data e{}\@secondoftwo\edef{####2}} -\protected\def\ekvd@t@gdata{\ekvd@type@data g{}\@secondoftwo\gdef{####2}} -\protected\def\ekvd@t@xdata{\ekvd@type@data x{}\@secondoftwo\xdef{####2}} -\protected\def\ekvd@t@dataT{\ekvd@type@data{}T\@gobble\def{}} -\protected\def\ekvd@t@edataT{\ekvd@type@data eT\@gobble\edef{}} -\protected\def\ekvd@t@gdataT{\ekvd@type@data gT\@gobble\gdef{}} -\protected\def\ekvd@t@xdataT{\ekvd@type@data xT\@gobble\xdef{}} +\protected\def\ekvd@t@data + {\ekvd@type@data{}{}\@secondoftwo\edef{####2}{\unexpanded{##1}}} +\protected\def\ekvd@t@edata{\ekvd@type@data e{}\@secondoftwo\edef{####2}{##1}} +\protected\def\ekvd@t@gdata + {\ekvd@type@data g{}\@secondoftwo\xdef{####2}{\unexpanded{##1}}} +\protected\def\ekvd@t@xdata{\ekvd@type@data x{}\@secondoftwo\xdef{####2}{##1}} +\protected\def\ekvd@t@dataT{\ekvd@type@data{}T\@gobble\edef{}{\unexpanded{##1}}} +\protected\def\ekvd@t@edataT{\ekvd@type@data eT\@gobble\edef{}{##1}} +\protected\def\ekvd@t@gdataT + {\ekvd@type@data gT\@gobble\xdef{}{\unexpanded{##1}}} +\protected\def\ekvd@t@xdataT{\ekvd@type@data xT\@gobble\xdef{}{##1}} \protected\def\ekvd@type@box#1#2#3#4% {% - \ekvd@assert@filledarg{#1box #3}{#4}% + \ekvd@assert@filledarg{#4}% {% \ekvd@newreg#4{box}% - \protected\ekvd@long\ekvdef\ekvd@set{#3}% - {#2\setbox#4\hbox{\begingroup##1\endgroup}}% + \ekvd@ifalso + {% + \let\ekvd@prot\protected + \ekvd@add@val{#3}{#2\setbox#4\hbox{\begingroup##1\endgroup}}{}% + }% + {% + \protected\ekvd@long\ekvdef\ekvd@set{#3}% + {#2\setbox#4\hbox{\begingroup##1\endgroup}}% + }% }% } \protected\def\ekvd@t@box{\ekvd@type@box{}{}} \protected\def\ekvd@t@gbox{\ekvd@type@box g\global} \protected\def\ekvd@type@toks#1#2#3#4% {% - \ekvd@assert@filledarg{#1toks #3}{#4}% + \ekvd@assert@filledarg{#4}% {% \ekvd@newreg#4{toks}% - \protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4{##1}}% + \ekvd@ifalso + {% + \let\ekvd@prot\protected + \ekvd@add@val{#3}{#2#4{##1}}{}% + }% + {\protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4{##1}}}% }% } \protected\def\ekvd@t@toks{\ekvd@type@toks{}{}} \protected\def\ekvd@t@gtoks{\ekvd@type@toks{g}\global} \protected\def\ekvd@type@apptoks#1#2#3#4% {% - \ekvd@assert@filledarg{#1apptoks #3}{#4}% + \ekvd@assert@filledarg{#4}% {% \ekvd@newreg#4{toks}% - \protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4\expandafter{\the#4##1}}% + \ekvd@ifalso + {% + \let\ekvd@prot\protected + \ekvd@add@val{#3}{#2#4\expandafter{\the#4##1}}{}% + }% + {% + \protected\ekvd@long\ekvdef\ekvd@set{#3}% + {#2#4\expandafter{\the#4##1}}% + }% }% } \protected\def\ekvd@t@apptoks{\ekvd@type@apptoks{}{}} \protected\def\ekvd@t@gapptoks{\ekvd@type@apptoks{g}\global} \protected\def\ekvd@type@reg#1#2#3#4#5#6#7% {% - \ekvd@assert@filledarg{#1 #6}{#7}% + \ekvd@assert@filledarg{#7}% {% \ekvd@newreg#7{#2}% - \protected\ekvd@long\ekvdef\ekvd@set{#6}{#3#7=#4##1#5\relax}% + \ekvd@ifalso + {% + \let\evkd@prot\protected + \ekvd@add@val{#6}{#3#7=#4##1#5\relax}{}% + }% + {\protected\ekvd@long\ekvdef\ekvd@set{#6}{#3#7=#4##1#5\relax}}% }% } \protected\def\ekvd@t@int{\ekvd@type@reg{int}{count}{}{}{}} @@ -279,31 +340,43 @@ \protected\def\ekvd@t@xskip{\ekvd@type@reg{xskip}{skip}\global\glueexpr\relax} \protected\def\ekvd@type@store#1#2#3#4% {% - \ekvd@assert@filledarg{#1store #3}{#4}% + \ekvd@assert@filledarg{#4}% {% - \unless\ifdefined#4\let#4\ekvd@empty\fi - \protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4{\unexpanded{##1}}}% + \ekvd@newlet#4\ekvd@empty + \ekvd@ifalso + {% + \let\ekvd@prot\protected + \ekvd@add@val{#3}{#2#4{\unexpanded{##1}}}{}% + }% + {\protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4{\unexpanded{##1}}}}% }% } \protected\def\ekvd@t@store{\ekvd@type@store{}\edef} \protected\def\ekvd@t@gstore{\ekvd@type@store{g}\xdef} \protected\def\ekvd@type@estore#1#2#3#4% {% - \ekvd@assert@filledarg{#1store #3}{#4}% + \ekvd@assert@filledarg{#4}% {% \ekvd@newlet#4\ekvd@empty - \protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4{##1}}% + \ekvd@ifalso + {% + \let\ekvd@prot\protected + \ekvd@add@val{#3}{#2#4{##1}}{}% + }% + {\protected\ekvd@long\ekvdef\ekvd@set{#3}{#2#4{##1}}}% }% } \protected\def\ekvd@t@estore{\ekvd@type@estore{e}\edef} \protected\def\ekvd@t@xstore{\ekvd@type@estore{x}\xdef} -\protected\long\def\ekvd@type@meta#1#2#3#4#5% +\protected\long\def\ekvd@type@meta#1#2#3#4#5#6#7#8% {% - \ekvd@assert@filledarg{#1meta #4}{#5}% + \ekvd@assert@filledarg{#8}% {% \edef\ekvd@tmp{\ekvd@set}% - \expandafter\ekvd@type@meta@a\expandafter{\ekvd@tmp}{#5}{#3}% - #2\ekvd@set{#4}\ekvd@tmp + \expandafter\ekvd@type@meta@a\expandafter{\ekvd@tmp}{#8}{#3}% + \ekvd@ifalso + {\ekvd@exp@Nno#4{#7}{\ekvd@tmp#5}{#6}}% + {#2\ekvd@set{#7}\ekvd@tmp}% }% } \protected\long\def\ekvd@type@meta@a#1#2% @@ -318,34 +391,43 @@ {% \ekvd@prot\ekvd@long\def\ekvd@tmp#2{#1}% } -\protected\def\ekvd@t@meta{\ekvd@type@meta{}\ekvlet{##1}} -\protected\long\def\ekvd@t@nmeta#1#2% +\protected\def\ekvd@t@meta{\ekvd@type@meta{}\ekvlet{##1}\ekvd@add@val{{##1}}{}} +\protected\def\ekvd@t@nmeta {% - \ekvd@assert@not@long{nmeta #1}% - \ekvd@type@meta n\ekvletNoVal{}{#1}{#2}% + \ekvd@assert@not@long + \ekvd@type@meta + n\ekvletNoVal{}\ekvd@add@noval{}\ekvd@assert@not@long@also } -\protected\long\def\ekvd@type@smeta#1#2#3#4#5% +\protected\long\def\ekvd@type@smeta#1#2#3#4#5#6#7#8% {% - \ekvd@assert@twoargs{s#1meta #4}{#5}% + \ekvd@assert@twoargs{#8}% {% - \ekvd@type@meta@a#5{#3}% - #2\ekvd@set{#4}\ekvd@tmp + \ekvd@type@meta@a#8{#3}% + \ekvd@ifalso + {\ekvd@exp@Nno#4{#7}{\ekvd@tmp#5}{#6}}% + {#2\ekvd@set{#7}\ekvd@tmp}% }% } -\protected\def\ekvd@t@smeta{\ekvd@type@smeta{}\ekvlet{##1}} -\protected\long\def\ekvd@t@snmeta#1#2% +\protected\def\ekvd@t@smeta + {\ekvd@type@smeta{}\ekvlet{##1}\ekvd@add@val{{##1}}{}} +\protected\def\ekvd@t@snmeta {% - \ekvd@assert@not@long{snmeta #1}% - \ekvd@type@smeta n\ekvletNoVal{}{#1}{#2}% + \ekvd@assert@not@long + \ekvd@type@smeta + n\ekvletNoVal{}\ekvd@add@noval{}\ekvd@assert@not@long@also } \protected\def\ekvd@type@choice#1#2% {% - \ekvd@assert@not@long{#1 #2}% + \ekvd@assert@not@long \ekvd@prot\edef\ekvd@tmp##1% {% \unexpanded{\ekvd@h@choice}{\ekvd@choice@name\ekvd@set{#2}{##1}}% }% - \ekvlet\ekvd@set{#2}\ekvd@tmp + \ekvd@ifalso + {% + \ekvd@exp@Nno\ekvd@add@val{#2}{\ekvd@tmp{##1}}\ekvd@assert@not@long@also + }% + {\ekvlet\ekvd@set{#2}\ekvd@tmp}% } \protected\def\ekvd@populate@choice {% @@ -353,12 +435,12 @@ } \protected\long\def\ekvd@populate@choice@noarg#1% {% - \expandafter\ekvd@err@missing@definition\expandafter{\ekvd@set@choice : #1}% + \expandafter\ekvd@err@missing@definition@msg\expandafter{\ekvd@cur : #1}% } \protected\long\def\ekvd@populate@choice@#1#2% {% \ekvd@clear@prefixes - \expandafter\ekvd@assert@arg\expandafter{\ekvd@set@choice : #1}{#2}% + \expandafter\ekvd@assert@arg@msg\expandafter{\ekvd@cur : #1}{#2}% {% \ekvd@ifspace{#1}% {\ekvd@choice@prefix\ekv@mark#1\ekv@stop}% @@ -391,19 +473,20 @@ } \protected\def\ekvd@choice@p@protected{\let\ekvd@prot\protected} \let\ekvd@choice@p@protect\ekvd@choice@p@protected -\protected\def\ekvd@choice@p@long\ekvd@ifspace#1% +\protected\def\ekvd@choice@invalid@p#1\ekvd@ifspace#2% {% - \expandafter\ekvd@choice@p@long@\expandafter{\ekv@gobble@mark#1}% - \ekvd@ifspace{#1}% + \expandafter\ekvd@choice@invalid@p@\expandafter{\ekv@gobble@mark#2}{#1}% + \ekvd@ifspace{#2}% } -\protected\def\ekvd@choice@p@long@#1% +\protected\def\ekvd@choice@invalid@p@#1#2% {% - \expandafter\ekvd@err@no@long\expandafter - {\ekvd@set@choice : long #1}% + \expandafter\ekvd@err@no@prefix@msg\expandafter{\ekvd@cur : #2 #1}{#2}% } +\protected\def\ekvd@choice@p@long{\ekvd@choice@invalid@p{long}}% +\protected\def\ekvd@choice@p@also{\ekvd@choice@invalid@p{also}}% \protected\long\def\ekvd@t@choice#1#2% {% - \ekvd@assert@arg{choice #1}{#2}% + \ekvd@assert@arg{#2}% {% \ekvd@type@choice{choice}{#1}% \def\ekvd@set@choice{#1}% @@ -412,9 +495,10 @@ } \protected\long\expandafter\def\csname ekvd@t@unknown-choice\endcsname#1#2% {% - \ekvd@assert@arg{unknown-choice #1}{#2}% + \ekvd@assert@arg{#2}% {% - \ekvd@assert@not@long{unknown-choice #1}% + \ekvd@assert@not@long + \ekvd@assert@not@also \ekvd@prot\expandafter \def\csname\ekvd@unknown@choice@name\ekvd@set{#1}\endcsname##1{#2}% }% @@ -433,18 +517,73 @@ \fi #1% } +\protected\long\def\ekvd@add@val#1#2#3% + {% + \ekvd@assert@val{#1}% + {% + \expandafter\ekvd@add@aux\csname\ekv@name\ekvd@set{#1}\endcsname{{##1}}% + {#1}{#2}{\ekvd@long\ekvdef}{#3}% + }% + } +\protected\long\def\ekvd@add@noval#1#2#3% + {% + \ekvd@assert@noval{#1}% + {% + \expandafter\ekvd@add@aux\csname\ekv@name\ekvd@set{#1}N\endcsname{}% + {#1}{#2}\ekvdefNoVal{#3}% + }% + } +\protected\long\def\ekvd@add@aux#1#2% + {% + \ekvd@extract@prefixes#1% + \expandafter\ekvd@add@aux@\expandafter{#1#2}% + } +\protected\long\def\ekvd@add@aux@#1#2#3#4#5% + {% + #5% + \ekvd@prot#4\ekvd@set{#2}{#1#3}% + } +\protected\def\ekvd@extract@prefixes#1% + {% + \expandafter\ekvd@extract@prefixes@\meaning#1\ekvd@stop + } +\protected\def\ekvd@extract@prefixes@#1#2#3% + {% + \protected\def\ekvd@extract@prefixes@##1#1##2\ekvd@stop + {% + \ekvd@extract@prefixes@long + ##1\ekvd@mark\@firstofone#2\ekvd@mark\@gobble\ekvd@stop + {\let\ekvd@long\long}% + \ekvd@extract@prefixes@prot + ##1\ekvd@mark\@firstofone#3\ekvd@mark\@gobble\ekvd@stop + {\let\ekvd@prot\protected}% + }% + \protected\def\ekvd@extract@prefixes@long##1#2##2\ekvd@mark##3##4\ekvd@stop + {##3}% + \protected\def\ekvd@extract@prefixes@prot##1#3##2\ekvd@mark##3##4\ekvd@stop + {##3}% + } +\begingroup +\edef\ekvd@tmp + {% + \endgroup + \ekvd@extract@prefixes@ + {\detokenize{macro:}}% + {\string\long}% + {\string\protected}% + } +\ekvd@tmp \protected\def\ekvd@newlet#1#2% {% - \unless\ifdefined#1\let#1#2\fi + \ifdefined#1\ekv@fi@gobble\fi\@firstofone{\let#1#2}% } \protected\def\ekvd@newreg#1#2% {% - \unless\ifdefined#1\csname new#2\endcsname#1\fi + \ifdefined#1\ekv@fi@gobble\fi\@firstofone{\csname new#2\endcsname#1}% } -\long\def\ekvd@assert@twoargs#1#2% +\long\def\ekvd@assert@twoargs#1% {% - \ekvd@ifnottwoargs{#2}% - {\ekvd@err@missing@definition{#1}}% + \ekvd@ifnottwoargs{#1}{\ekvd@err@missing@definition}% } \long\def\ekvd@ifnottwoargs#1% {% @@ -452,10 +591,55 @@ \ekv@ifempty@false\ekv@ifempty@A\ekv@ifempty@B\@firstoftwo } \long\def\ekvd@ifempty@gtwo#1#2{\ekv@ifempty@\ekv@ifempty@A} -\long\def\ekvd@assert@arg#1#2% +\protected\def\ekvd@assert@val#1% {% - \ekvd@ifnoarg{#2}% - {\ekvd@err@missing@definition{#1}}% + \ekvifdefined\ekvd@set{#1}% + {\expandafter\ekvd@assert@val@\csname\ekv@name\ekvd@set{#1}\endcsname}% + {% + \ekvifdefinedNoVal\ekvd@set{#1}% + \ekvd@err@add@val@on@noval + {\ekvd@err@undefined@key{#1}}% + \@gobble + }% + } +\protected\def\ekvd@assert@val@#1% + {% + \expandafter\ekvd@extract@args\meaning#1\ekvd@stop + \unless\ifx\ekvd@extracted@args\ekvd@one@arg@string + \ekvd@err@unsupported@arg + \fi + \@firstofone + }% +\protected\def\ekvd@assert@noval#1% + {% + \ekvifdefinedNoVal\ekvd@set{#1}% + {\expandafter\ekvd@assert@noval@\csname\ekv@name\ekvd@set{#1}N\endcsname}% + {% + \ekvifdefined\ekvd@set{#1}% + \ekvd@err@add@noval@on@val + {\ekvd@err@undefined@key{#1}}% + \@gobble + }% + } +\protected\def\ekvd@assert@noval@#1% + {% + \expandafter\ekvd@extract@args\meaning#1\ekvd@stop + \unless\ifx\ekvd@extracted@args\ekvd@empty + \ekvd@err@unsupported@arg + \fi + \@firstofone + } +\protected\def\ekvd@extract@args#1% + {% + \protected\def\ekvd@extract@args##1#1##2->##3\ekvd@stop + {\def\ekvd@extracted@args{##2}}% + } +\expandafter\ekvd@extract@args\expandafter{\detokenize{macro:}} +\edef\ekvd@one@arg@string{\string#1} +\long\def\ekvd@assert@arg#1{\ekvd@ifnoarg{#1}\ekvd@err@missing@definition} +\long\def\ekvd@assert@arg@msg#1#2% + {% + \ekvd@ifnoarg{#2}{\ekvd@err@missing@definition@msg{#1}}% } \long\def\ekvd@ifnoarg#1% {% @@ -468,10 +652,9 @@ {% #1% } -\long\def\ekvd@assert@filledarg#1#2% +\long\def\ekvd@assert@filledarg#1% {% - \ekvd@ifnoarg@or@empty{#2}% - {\ekvd@err@missing@definition{#1}}% + \ekvd@ifnoarg@or@empty{#1}\ekvd@err@missing@definition } \long\def\ekvd@ifnoarg@or@empty#1% {% @@ -479,13 +662,19 @@ \@firstoftwo {\ekv@ifempty{#1}}% } -\long\def\ekvd@assert@not@long#1% +\def\ekvd@assert@not@long{\ifx\ekvd@long\long\ekvd@err@no@prefix{long}\fi} +\def\ekvd@assert@not@protected {% - \ifx\ekvd@long\long\ekvd@err@no@long{#1}\fi + \ifx\ekvd@prot\protected\ekvd@err@no@prefix{protected}\fi } -\long\def\ekvd@assert@not@protected#1% +\def\ekvd@assert@not@also{\ekvd@ifalso{\ekvd@err@no@prefix{also}}{}} +\def\ekvd@assert@not@long@also {% - \ifx\ekvd@prot\protected\ekvd@err@no@protected{#1}\fi + \ifx\ekvd@long\long\ekvd@err@no@prefix@also{long}\fi + } +\def\ekvd@assert@not@protected@also + {% + \ifx\ekvd@prot\protected\ekvd@err@no@prefix@also{protected}\fi } \long\def\ekvd@ifspace#1% {% @@ -496,23 +685,41 @@ {% \ekv@ifempty@\ekv@ifempty@A } -\protected\def\ekvd@err@missing@definition#1% - {\errmessage{expkv-def Error: Missing definition for key `\unexpanded{#1}'}} -\protected\def\ekvd@err@missing@prefix#1% - {\errmessage{expkv-def Error: Missing prefix for key `\unexpanded{#1}'}} +\protected\def\ekvd@errm#1{\errmessage{expkv-def Error: #1}} +\protected\def\ekvd@err@missing@definition + {\ekvd@errm{Missing definition for key `\ekvd@cur'}} +\protected\def\ekvd@err@missing@definition@msg#1% + {\ekvd@errm{Missing definition for key `\unexpanded{#1}'}} +\protected\def\ekvd@err@missing@type + {\ekvd@errm{Missing type prefix for key `\ekvd@cur'}} \protected\def\ekvd@err@undefined@prefix#1% - {\errmessage{expkv-def Error: Undefined prefix `\unexpanded{#1}'}} -\protected\def\ekvd@err@undefined@key#1% - {\errmessage{expkv-def Error: Undefined key `\unexpanded{#1}'}} -\protected\def\ekvd@err@no@protected#1% {% - \errmessage - {expkv-def Error: prefix `protected' not accepted for `\unexpanded{#1}'}% + \ekvd@errm + {Undefined prefix `\unexpanded{#1}' found while processing `\ekvd@cur'}% } -\protected\def\ekvd@err@no@long#1% +\protected\def\ekvd@err@undefined@key#1% + {% + \ekvd@errm + {Undefined key `\unexpanded{#1}' found while processing `\ekvd@cur'}% + } +\protected\def\ekvd@err@no@prefix#1% + {\ekvd@errm{prefix `#1' not accepted in `\ekvd@cur'}} +\protected\def\ekvd@err@no@prefix@msg#1#2% + {\ekvd@errm{prefix `#2' not accepted in `\unexpanded{#1}'}} +\protected\def\ekvd@err@no@prefix@also#1% + {\ekvd@errm{`\ekvd@cur' not allowed with a `#1' key}} +\protected\def\ekvd@err@add@val@on@noval + {\ekvd@errm{`\ekvd@cur' not allowed with a NoVal key}} +\protected\def\ekvd@err@add@noval@on@val + {\ekvd@errm{`\ekvd@cur' not allowed with a value taking key}} +\protected\def\ekvd@err@unsupported@arg\fi\@firstofone#1% {% - \errmessage - {expkv-def Error: prefix `long' not accepted for `\unexpanded{#1}'}% + \fi + \ekvd@errm + {% + Existing key-macro has the unsupported argument string + `\ekvd@extracted@args' for key `\ekvd@cur'% + }% } \def\ekvd@err@choice@invalid#1% {% |