From f1991724088484845cc165c43948922dc85da9bf Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 10 Apr 2021 21:10:10 +0000 Subject: expkv (10apr21) git-svn-id: svn://tug.org/texlive/trunk@58815 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/generic/expkv/expkv.tex | 131 +++++++++++++++++++++++--- Master/texmf-dist/tex/latex/expkv/expkv.sty | 2 +- 2 files changed, 117 insertions(+), 16 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/generic/expkv/expkv.tex b/Master/texmf-dist/tex/generic/expkv/expkv.tex index 79cbaac18b9..99171b0f1de 100644 --- a/Master/texmf-dist/tex/generic/expkv/expkv.tex +++ b/Master/texmf-dist/tex/generic/expkv/expkv.tex @@ -13,7 +13,7 @@ %% See http://www.latex-project.org/lppl.txt %% -------------------------------------------------------------- %% -%% Copyright (C) 2020 Jonathan P. Spratte +%% Copyright (C) 2020-2021 Jonathan P. Spratte %% %% This work may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this license or @@ -39,8 +39,8 @@ \errmessage{expkv requires e-TeX} \expandafter\endinput \fi -\def\ekvVersion{1.6} -\def\ekvDate{2020-12-28} +\def\ekvVersion{1.7} +\def\ekvDate{2021-04-09} \csname ekv@tmp\endcsname \expandafter\chardef\csname ekv@tmp\endcsname=\catcode`\@ \catcode`\@=11 @@ -130,6 +130,21 @@ \long\def\ekv@exparg@#1#2{#2{#1}}% \long\def\ekv@expargtwice#1#2{\expandafter\ekv@expargtwice@\expandafter{#2}{#1}} \def\ekv@expargtwice@{\expandafter\ekv@exparg@\expandafter} +\ekv@exparg{\long\def\ekv@csv@loop#1#2,}% + {% + \expandafter + \ekv@gobble@from@mark@to@stop + \expandafter#\expandafter2\expandafter\ekv@csv@loop@end\expandafter + \ekv@stop + \ekv@strip{#2}{\ekv@csv@loop@do{#1}}% + \ekv@csv@loop{#1}\ekv@mark + } +\long\def\ekv@csv@loop@do#1#2{\unexpanded{#1{#2}}} +\long\expandafter\def\expandafter\ekv@csv@loop@end + \expandafter\ekv@stop + \ekv@strip{#1}#2% + \ekv@csv@loop#3\ekv@mark + {} \def\ekv@name@set#1{ekv#1(} \def\ekv@name@key#1{#1)} \edef\ekv@name @@ -225,8 +240,95 @@ \unexpanded\expandafter{\ekv@undefined@set{#1}\endcsname{#1}}% }% {\unexpanded\expandafter{\ekv@name{#3}{#4}}}% - }% + } \expandafter\ekvdef\ekvdefNoVal +\protected\def\ekvredirectunknown + {% + \ekv@defredirectunknown + \ekv@redirect@kv + \ekv@err@redirect@kv@notfound + {\long\ekvdefunknown}% + \ekv@redirectunknown@aux + } +\protected\def\ekvredirectunknownNoVal + {% + \ekv@defredirectunknown + \ekv@redirect@k + \ekv@err@redirect@k@notfound + \ekvdefunknownNoVal + \ekv@redirectunknownNoVal@aux + } +\protected\def\ekv@defredirectunknown#1#2#3#4#5#6% + {% + \begingroup + \edef\ekv@tmp + {% + \ekv@csv@loop#1\ekv@mark#6,\ekv@stop,% + \unexpanded{#2}% + {\ekv@csv@loop{}\ekv@mark#5,#6,\ekv@stop,}% + }% + \ekv@expargtwice + {\endgroup#3{#5}}% + {\expandafter#4\ekv@tmp\ekv@stop}% + } +\def\ekv@redirectunknown@aux#1{#1{##1}{##2}} +\def\ekv@redirectunknownNoVal@aux#1{#1{##1}} +\def\ekv@redirect@k#1#2#3#4% + {% + \ekv@if@lastnamedcs + {% + \def\ekv@redirect@k##1##2##3% + {% + \ifcsname#1\endcsname\ekv@redirect@k@a\fi + ##3{##1}% + }% + \def\ekv@redirect@k@a\fi{\fi\expandafter\ekv@redirect@k@b\lastnamedcs}% + \long\def\ekv@redirect@kv##1##2##3##4% + {% + \ifcsname#2\endcsname\ekv@redirect@kv@a\fi\@gobble{##1}% + ##4{##1}{##2}% + } + \def\ekv@redirect@kv@a\fi\@gobble + {\fi\expandafter\ekv@redirect@kv@b\lastnamedcs}% + } + {% + \def\ekv@redirect@k##1##2##3% + {% + \ifcsname#1\endcsname\ekv@redirect@k@a\fi\ekv@redirect@k@a@ + #1\endcsname + ##3{##1}% + }% + \def\ekv@redirect@k@a@#3\endcsname{}% + \def\ekv@redirect@k@a\fi\ekv@redirect@k@a@ + {\fi\expandafter\ekv@redirect@k@b\csname}% + \long\def\ekv@redirect@kv##1##2##3##4% + {% + \ifcsname#2\endcsname\ekv@redirect@kv@a\fi\ekv@redirect@kv@a@ + #2\endcsname{##1}% + ##4{##1}{##2}% + } + \long\def\ekv@redirect@kv@a@#4\endcsname##3{}% + \def\ekv@redirect@kv@a\fi\ekv@redirect@kv@a@ + {\fi\expandafter\ekv@redirect@kv@b\csname}% + } + } +\def\ekv@redirect@kv#1\detokenize#2#3\ekv@stop{\unexpanded{#1#2#3}} +\edef\ekv@redirect@kv + {% + {\expandafter\ekv@redirect@kv\ekv@name{#2}{#1}N\ekv@stop}% + {\expandafter\ekv@redirect@kv\ekv@name{#3}{#2}\ekv@stop}% + {\expandafter\ekv@redirect@kv\ekv@name{#1}{#2}N\ekv@stop}% + {\expandafter\ekv@redirect@kv\ekv@name{#1}{#2}\ekv@stop}% + } +\expandafter\ekv@redirect@k\ekv@redirect@kv +\def\ekv@redirect@k@b#1% + {\ifx\relax#1\ekv@redirect@k@c\fi\ekv@redirect@k@d#1} +\def\ekv@redirect@k@c\fi\ekv@redirect@k@d#1{\fi} +\def\ekv@redirect@k@d#1#2\ekv@stop{#1} +\def\ekv@redirect@kv@b#1% + {\ifx\relax#1\ekv@redirect@kv@c\fi\ekv@redirect@kv@d#1} +\long\def\ekv@redirect@kv@c\fi\ekv@redirect@kv@d#1#2{\fi} +\long\def\ekv@redirect@kv@d#1#2#3\ekv@stop{#1{#2}} \edef\ekv@defsetmacro {% \unexpanded{\ifx#1\relax\edef#1##1}% @@ -540,24 +642,23 @@ \ekv@exparg{\ekv@zero\ekv@exparg{\long\def#1##1}}% {\ekvsetSneaked{#2}{#3}{##1}}% } -\begingroup -\edef\ekv@err +\def\ekv@err#1% {% - \endgroup - \unexpanded{\long\def\ekv@err}##1% - {% - \unexpanded{\expandafter\ekv@err@\@firstofone}% - {\unexpanded\expandafter{\csname ! expkv Error:\endcsname}##1.}% - \unexpanded{\ekv@stop}% - }% + \long\def\ekv@err##1{\expandafter\ekv@err@\@firstofone{#1##1.}\ekv@stop}% } -\ekv@err +\begingroup\expandafter\endgroup +\expandafter\ekv@err\csname ! expkv Error:\endcsname \def\ekv@err@{\expandafter\ekv@gobbleto@stop} \long\def\ekv@err@common #1#2{\expandafter\ekv@err@common@\string#2{#1}} -\long\def\ekv@err@common@#1`#2' #3.#4#5{\ekv@err{#4 (`#5', set `#2')}} +\ekv@exparg{\long\def\ekv@err@common@#1`#2' #3.#4#5}% + {\ekv@err{#4 (`#5', set `#2')}} \ekv@exparg{\long\def\ekv@err@unknown#1}{\ekv@err@common{unknown key}{#1}} \ekv@exparg{\long\def\ekv@err@noarg #1}{\ekv@err@common{value forbidden}{#1}} \ekv@exparg{\long\def\ekv@err@reqval #1}{\ekv@err@common{value required}{#1}} +\ekv@exparg{\long\def\ekv@err@redirect@kv@notfound#1#2#3\ekv@stop}% + {\ekv@err{no key `#2' in sets #3}} +\ekv@exparg{\def\ekv@err@redirect@k@notfound#1#2\ekv@stop}% + {\ekv@err{no NoVal key `#1' in sets #2}} \catcode`\@=\ekv@tmp %% %% diff --git a/Master/texmf-dist/tex/latex/expkv/expkv.sty b/Master/texmf-dist/tex/latex/expkv/expkv.sty index 88d7963187e..0d6911afc2c 100644 --- a/Master/texmf-dist/tex/latex/expkv/expkv.sty +++ b/Master/texmf-dist/tex/latex/expkv/expkv.sty @@ -13,7 +13,7 @@ %% See http://www.latex-project.org/lppl.txt %% -------------------------------------------------------------- %% -%% Copyright (C) 2020 Jonathan P. Spratte +%% Copyright (C) 2020-2021 Jonathan P. Spratte %% %% This work may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this license or -- cgit v1.2.3