From 8e19c1d03bedd949c662d0011aa264b371c0cc11 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 21 Nov 2021 21:12:01 +0000 Subject: expkv-cs (21nov21) git-svn-id: svn://tug.org/texlive/trunk@61109 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/expkv-cs/README.md | 2 +- Master/texmf-dist/doc/latex/expkv-cs/expkv-cs.pdf | Bin 460837 -> 458679 bytes .../texmf-dist/source/latex/expkv-cs/expkv-cs.dtx | 152 +++++++++------------ .../texmf-dist/tex/generic/expkv-cs/expkv-cs.tex | 118 ++++++---------- 4 files changed, 112 insertions(+), 160 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/expkv-cs/README.md b/Master/texmf-dist/doc/latex/expkv-cs/README.md index 648b3b5a598..a04a4c4220a 100644 --- a/Master/texmf-dist/doc/latex/expkv-cs/README.md +++ b/Master/texmf-dist/doc/latex/expkv-cs/README.md @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- # expkv-cs -- define expandable key=val macros using expkv -Version 2021-09-20 v1.1a +Version 2021-11-21 v1.1b Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt diff --git a/Master/texmf-dist/doc/latex/expkv-cs/expkv-cs.pdf b/Master/texmf-dist/doc/latex/expkv-cs/expkv-cs.pdf index 130e142fb3e..24c83fda2cf 100644 Binary files a/Master/texmf-dist/doc/latex/expkv-cs/expkv-cs.pdf and b/Master/texmf-dist/doc/latex/expkv-cs/expkv-cs.pdf differ diff --git a/Master/texmf-dist/source/latex/expkv-cs/expkv-cs.dtx b/Master/texmf-dist/source/latex/expkv-cs/expkv-cs.dtx index ffb706b2212..c975e4931cf 100644 --- a/Master/texmf-dist/source/latex/expkv-cs/expkv-cs.dtx +++ b/Master/texmf-dist/source/latex/expkv-cs/expkv-cs.dtx @@ -1568,8 +1568,8 @@ and the derived files expkv-cs.pdf % \begin{macro}{\ekvcVersion,\ekvcDate} % We're on our first input, so lets store the version and date in a macro. % \begin{macrocode} -\def\ekvcVersion{1.1a} -\def\ekvcDate{2021-09-20} +\def\ekvcVersion{1.1b} +\def\ekvcDate{2021-11-21} % \end{macrocode} % \end{macro} % @@ -1783,7 +1783,7 @@ and the derived files expkv-cs.pdf % \begin{macro}[internal] % { % \ekvc@SetupSplitKeys, \ekvc@SetupSplitKeys@a, \ekvc@SetupSplitKeys@b, -% \ekvc@SetupSplitKeys@c, \ekvc@SetupSplitKeys@d +% \ekvc@SetupSplitKeys@c, \ekvc@SetupSplitKeys@d, \ekvc@SetupSplitKeys@e, % \ekvc@SetupSplitKeys@check@unknown,\ekvc@SetupSplitKeys@unknown % } % These macros parse the list of keys and set up the key macros. First we need @@ -1791,7 +1791,7 @@ and the derived files expkv-cs.pdf % \begin{macrocode} \protected\long\def\ekvc@SetupSplitKeys {% - \ekvc@keycount=0 + \ekvc@keycount=\ekv@zero \let\ekvc@any@long\ekv@empty \let\ekvc@initials\ekv@empty \ekvparse\ekvc@SetupSplitKeys@check@unknown\ekvc@SetupSplitKeys@a @@ -1829,20 +1829,15 @@ and the derived files expkv-cs.pdf % the value given to the key. Additionally we'll need a sorting macro for each % key count in use so we set it up with |\ekvc@setup@splitmacro|. % \begin{macrocode} -\protected\long\def\ekvc@SetupSplitKeys@d#1#2% +\protected\def\ekvc@SetupSplitKeys@d {% - \begingroup - \edef\ekvc@tmp - {% - \endgroup - \long\def\ekv@unexpanded{\ekvc@tmp}####1####2% - \ekv@unexpanded\expandafter - {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname}####3% - {% - ####2% - \ekv@unexpanded\expandafter - {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname}{####1}% - }% + \begingroup\expandafter\endgroup + \expandafter\ekvc@SetupSplitKeys@e + \csname ekvc@splitmark@\the\ekvc@keycount\endcsname + } +\protected\long\def\ekvc@SetupSplitKeys@e#1#2#3% + {% + \long\def\ekvc@tmp##1##2#1##3{##2#1{##1}}% % \end{macrocode} % The short variant needs a bit of special treatment. The key macro will be % short to throw the correct error, but since there might be long macros @@ -1850,25 +1845,16 @@ and the derived files expkv-cs.pdf % use a two step approach, first grabbing only the short argument, then % reordering. % \begin{macrocode} - \unless\ifx\ekvc@long\long - \let\ekv@unexpanded\expandafter - {\csname ekvc@\ekvc@set(\detokenize{#1})\endcsname\ekvc@tmp}% - \def\ekv@unexpanded{\ekvc@tmp}####1% - {% - \ekv@unexpanded\expandafter - {\csname ekvc@\ekvc@set(\detokenize{#1})\endcsname}% - {####1}% - }% - \fi - \def\ekv@unexpanded{\ekvc@initials}% - {% - \ekv@unexpanded\expandafter{\ekvc@initials}% - \ekv@unexpanded\expandafter - {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname{#2}}% - }% - }% - \ekvc@tmp - \ekvlet\ekvc@set{#1}\ekvc@tmp + \unless\ifx\ekvc@long\long + \expandafter\let\csname ekvc@\ekvc@set(#2)\endcsname\ekvc@tmp + \edef\ekvc@tmp##1% + {% + \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#2)\endcsname}% + {##1}% + }% + \fi + \ekvlet\ekvc@set{#2}\ekvc@tmp + \edef\ekvc@initials{\ekv@unexpanded\expandafter{\ekvc@initials#1{#3}}}% \ekvc@helpers@needed {\expandafter\ekvc@setup@splitmacro\expandafter{\the\ekvc@keycount}}% {}% @@ -2128,7 +2114,7 @@ and the derived files expkv-cs.pdf % \begin{macro}[internal] % { % \ekvc@SetupHashKeys,\ekvc@SetupHashKeys@a,\ekvc@SetupHashKeys@b, -% \ekvc@SetupHashKeys@c,\ekvc@SetupHashKeys@d +% \ekvc@SetupHashKeys@c,\ekvc@SetupHashKeys@d,\ekvc@SetupHashKeys@e, % \ekvc@SetupHashKeys@check@unknown,\ekvc@SetupHashKeys@unknown % } % This should look awfully familiar as well, since it's just the same as for @@ -2156,44 +2142,35 @@ and the derived files expkv-cs.pdf {\ekvc@SetupHashKeys@d{#1 #2}}% } % \end{macrocode} +% Again we build the marker, this time instead of a numbered one a named +% hashmark, inside a group to not actually define the macro used as a marker. +% \begin{macrocode} +\protected\long\def\ekvc@SetupHashKeys@d#1% + {% + \begingroup\expandafter\endgroup + \expandafter\ekvc@SetupHashKeys@e\csname ekvc@hashmark@#1\endcsname{#1}% + } +% \end{macrocode} % Yes, even the defining macro looks awfully familiar. Instead of numbered we % have named marks. Still the key macros grab everything up to their % respective mark and reorder the arguments. The same quirk is applied for % short keys. And instead of the |\ekvc@setup@splitmacro| we use % |\ekvc@setup@hashmacro|. % \begin{macrocode} -\protected\long\def\ekvc@SetupHashKeys@d#1#2% +\protected\long\def\ekvc@SetupHashKeys@e#1#2#3% {% - \begingroup - \edef\ekvc@tmp - {% - \endgroup - \long\def\ekv@unexpanded{\ekvc@tmp}####1####2% - \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - ####3% - {% - ####2% - \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - {####1}% - }% - \unless\ifx\ekvc@long\long - \let\ekv@unexpanded\expandafter - {\csname ekvc@\ekvc@set(#1)\endcsname\ekvc@tmp}% - \def\ekv@unexpanded{\ekvc@tmp}####1% - {% - \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#1)\endcsname}% - {####1}% - }% - \fi - \def\ekv@unexpanded{\ekvc@initials}% - {% - \ekv@unexpanded\expandafter{\ekvc@initials}% - \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname{#2}}% - }% - }% - \ekvc@tmp - \ekvlet\ekvc@set{#1}\ekvc@tmp - \ekvc@setup@hashmacro{#1}% + \long\def\ekvc@tmp##1##2#1##3{##2#1{##1}}% + \unless\ifx\ekvc@long\long + \expandafter\let\csname ekvc@\ekvc@set(#2)\endcsname\ekvc@tmp + \edef\ekvc@tmp##1% + {% + \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#2)\endcsname}% + {##1}% + }% + \fi + \ekvlet\ekvc@set{#2}\ekvc@tmp + \edef\ekvc@initials{\ekv@unexpanded\expandafter{\ekvc@initials#1{#3}}}% + \ekvc@setup@hashmacro{#2}% } % \end{macrocode} % \begin{macrocode} @@ -2479,7 +2456,10 @@ and the derived files expkv-cs.pdf % \end{macro} % % \begin{macro}[internal] -% {\ekvc@change,\ekvc@change@a,\ekvc@change@b,\ekvc@change@c} +% { +% \ekvc@change ,\ekvc@change@a,\ekvc@change@b, +% \ekvc@change@c,\ekvc@change@d,\ekvc@change@e +% } % First we need to see whether the macro is currently |\long|. For this we get % the meaning and will parse it. |#1| is the macro name in which we want to % change the defaults. @@ -2502,11 +2482,12 @@ and the derived files expkv-cs.pdf \expandafter\ekvc@change@a\expandafter{\detokenize{macro:}} % \end{macrocode} % Next we expand the macro once to get its contents (including the current -% default values with their markers). |#1| is either |\long| or empty, |#2| is -% the macro. +% default values with their markers) and place |\ekvc@stop| instead of an +% argument as a marker for the last step. |#1| is either |\long| or empty, +% |#2| is the macro. % \begin{macrocode} \protected\def\ekvc@change@b#1#2% - {\expandafter\ekvc@change@c\expandafter{#2{##1}}{#1}#2} + {\expandafter\ekvc@change@c\expandafter{#2\ekvc@stop}{#1}#2} % \end{macrocode} % Here we place an unbalanced closing brace after the expansion of the macro. % Then we just parse the \kv-list with |\ekvset|, that will exchange the @@ -2518,25 +2499,24 @@ and the derived files expkv-cs.pdf % \begin{macrocode} \ekv@exparg{\protected\long\def\ekvc@change@c#1#2#3#4}% {% - \expandafter\iffalse\expandafter{\expandafter\fi + \expandafter\iffalse\expandafter{\expandafter{\expandafter\fi \ekvset{\string#3}{#4}% \ekvc@change@d{#2}{#3}% #1% - }% + }}% } % \end{macrocode} -% The final step needs to put an unbalanced opening brace after |\def|. We do -% that with the help of a temporary macro which stores everything necessary -% for |\def| and expand an |\iffalse}\fi| construct to leave a single -% opening brace. |#1| will be either empty or |\long| and |#2| is the macro. -% Each of the macros defined with \expkvc\ takes exactly one parameter, so we -% put that here as |####1|. +% The final step needs to put an unbalanced opening brace after |\edef|. Also +% we have to protect everything from further expanding with the exception of +% the redefined macro's argument, which is why we placed the |\ekvc@stop| +% earlier. Then we need to also protect the rest of the contents from further +% expanding using |\unexpanded| with another unbalanced opening brace. +% |#1| will be either empty or |\long| and |#2| is the macro. % \begin{macrocode} \protected\def\ekvc@change@d#1#2% - {% - \def\ekvc@tmp{#1\def#2####1}% - \expandafter\ekvc@tmp\expandafter{\iffalse}\fi - } + {#1\edef#2##1{\expandafter\ekvc@change@e\iffalse}\fi} +\long\def\ekvc@change@e#1\ekvc@stop + {\ekv@unexpanded{#1}##1\ekv@unexpanded\expandafter{\iffalse}\fi} % \end{macrocode} % \end{macro} % @@ -3018,8 +2998,8 @@ and the derived files expkv-cs.pdf % \end{macro} % % \begin{macro}{\ekvcFlagIf} -% As already explained, truthiness is defined as a flag's height is odd, so we -% just branch accordingly here. +% As already explained, truthiness is defined as a flag's height being odd, so +% we just branch accordingly here. % \begin{macrocode} \def\ekvcFlagIf#1% {% diff --git a/Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex b/Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex index 53b56d997d0..931c0c25ba3 100644 --- a/Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex +++ b/Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex @@ -36,8 +36,8 @@ \else \expandafter\endinput \fi -\def\ekvcVersion{1.1a} -\def\ekvcDate{2021-09-20} +\def\ekvcVersion{1.1b} +\def\ekvcDate{2021-11-21} \csname ekvc@tmp\endcsname \expandafter\chardef\csname ekvc@tmp\endcsname=\catcode`\@ \catcode`\@=11 @@ -149,7 +149,7 @@ } \protected\long\def\ekvc@SetupSplitKeys {% - \ekvc@keycount=0 + \ekvc@keycount=\ekv@zero \let\ekvc@any@long\ekv@empty \let\ekvc@initials\ekv@empty \ekvparse\ekvc@SetupSplitKeys@check@unknown\ekvc@SetupSplitKeys@a @@ -170,39 +170,25 @@ {\csname ekvc@split@p@#1\endcsname{#2}}% {\ekvc@SetupSplitKeys@d{#1 #2}}% } -\protected\long\def\ekvc@SetupSplitKeys@d#1#2% +\protected\def\ekvc@SetupSplitKeys@d {% - \begingroup - \edef\ekvc@tmp - {% - \endgroup - \long\def\ekv@unexpanded{\ekvc@tmp}####1####2% - \ekv@unexpanded\expandafter - {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname}####3% - {% - ####2% - \ekv@unexpanded\expandafter - {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname}{####1}% - }% - \unless\ifx\ekvc@long\long - \let\ekv@unexpanded\expandafter - {\csname ekvc@\ekvc@set(\detokenize{#1})\endcsname\ekvc@tmp}% - \def\ekv@unexpanded{\ekvc@tmp}####1% - {% - \ekv@unexpanded\expandafter - {\csname ekvc@\ekvc@set(\detokenize{#1})\endcsname}% - {####1}% - }% - \fi - \def\ekv@unexpanded{\ekvc@initials}% - {% - \ekv@unexpanded\expandafter{\ekvc@initials}% - \ekv@unexpanded\expandafter - {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname{#2}}% - }% - }% - \ekvc@tmp - \ekvlet\ekvc@set{#1}\ekvc@tmp + \begingroup\expandafter\endgroup + \expandafter\ekvc@SetupSplitKeys@e + \csname ekvc@splitmark@\the\ekvc@keycount\endcsname + } +\protected\long\def\ekvc@SetupSplitKeys@e#1#2#3% + {% + \long\def\ekvc@tmp##1##2#1##3{##2#1{##1}}% + \unless\ifx\ekvc@long\long + \expandafter\let\csname ekvc@\ekvc@set(#2)\endcsname\ekvc@tmp + \edef\ekvc@tmp##1% + {% + \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#2)\endcsname}% + {##1}% + }% + \fi + \ekvlet\ekvc@set{#2}\ekvc@tmp + \edef\ekvc@initials{\ekv@unexpanded\expandafter{\ekvc@initials#1{#3}}}% \ekvc@helpers@needed {\expandafter\ekvc@setup@splitmacro\expandafter{\the\ekvc@keycount}}% {}% @@ -391,38 +377,25 @@ {\csname ekvc@hash@p@#1\endcsname{#2}}% {\ekvc@SetupHashKeys@d{#1 #2}}% } -\protected\long\def\ekvc@SetupHashKeys@d#1#2% +\protected\long\def\ekvc@SetupHashKeys@d#1% {% - \begingroup - \edef\ekvc@tmp - {% - \endgroup - \long\def\ekv@unexpanded{\ekvc@tmp}####1####2% - \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - ####3% - {% - ####2% - \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - {####1}% - }% - \unless\ifx\ekvc@long\long - \let\ekv@unexpanded\expandafter - {\csname ekvc@\ekvc@set(#1)\endcsname\ekvc@tmp}% - \def\ekv@unexpanded{\ekvc@tmp}####1% - {% - \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#1)\endcsname}% - {####1}% - }% - \fi - \def\ekv@unexpanded{\ekvc@initials}% - {% - \ekv@unexpanded\expandafter{\ekvc@initials}% - \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname{#2}}% - }% - }% - \ekvc@tmp - \ekvlet\ekvc@set{#1}\ekvc@tmp - \ekvc@setup@hashmacro{#1}% + \begingroup\expandafter\endgroup + \expandafter\ekvc@SetupHashKeys@e\csname ekvc@hashmark@#1\endcsname{#1}% + } +\protected\long\def\ekvc@SetupHashKeys@e#1#2#3% + {% + \long\def\ekvc@tmp##1##2#1##3{##2#1{##1}}% + \unless\ifx\ekvc@long\long + \expandafter\let\csname ekvc@\ekvc@set(#2)\endcsname\ekvc@tmp + \edef\ekvc@tmp##1% + {% + \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#2)\endcsname}% + {##1}% + }% + \fi + \ekvlet\ekvc@set{#2}\ekvc@tmp + \edef\ekvc@initials{\ekv@unexpanded\expandafter{\ekvc@initials#1{#3}}}% + \ekvc@setup@hashmacro{#2}% } \protected\long\def\ekvc@SetupHashKeys@check@unknown#1% {% @@ -616,20 +589,19 @@ } \expandafter\ekvc@change@a\expandafter{\detokenize{macro:}} \protected\def\ekvc@change@b#1#2% - {\expandafter\ekvc@change@c\expandafter{#2{##1}}{#1}#2} + {\expandafter\ekvc@change@c\expandafter{#2\ekvc@stop}{#1}#2} \ekv@exparg{\protected\long\def\ekvc@change@c#1#2#3#4}% {% - \expandafter\iffalse\expandafter{\expandafter\fi + \expandafter\iffalse\expandafter{\expandafter{\expandafter\fi \ekvset{\string#3}{#4}% \ekvc@change@d{#2}{#3}% #1% - }% + }}% } \protected\def\ekvc@change@d#1#2% - {% - \def\ekvc@tmp{#1\def#2####1}% - \expandafter\ekvc@tmp\expandafter{\iffalse}\fi - } + {#1\edef#2##1{\expandafter\ekvc@change@e\iffalse}\fi} +\long\def\ekvc@change@e#1\ekvc@stop + {\ekv@unexpanded{#1}##1\ekv@unexpanded\expandafter{\iffalse}\fi} \def\ekvc@change@iflong#1% {% \protected\def\ekvc@change@iflong##1% -- cgit v1.2.3