summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/expkv-cs
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-06-20 19:56:27 +0000
committerKarl Berry <karl@freefriends.org>2021-06-20 19:56:27 +0000
commit2347cb3e8bc2c9276574d14461f4429c6b3c1bd4 (patch)
treeeb091127516eb112f601cab0c919848e8b6beb2e /Master/texmf-dist/tex/generic/expkv-cs
parent0e008fd431955e2802ab0abb5220e3bfb78256e6 (diff)
expkv-cs (20jun21)
git-svn-id: svn://tug.org/texlive/trunk@59655 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/expkv-cs')
-rw-r--r--Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex151
1 files changed, 128 insertions, 23 deletions
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 500356b7069..55ed7f01041 100644
--- a/Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex
+++ b/Master/texmf-dist/tex/generic/expkv-cs/expkv-cs.tex
@@ -35,11 +35,12 @@
\else
\expandafter\endinput
\fi
-\def\ekvcVersion{0.10}
-\def\ekvcDate{2021-06-03}
+\def\ekvcVersion{1.0}
+\def\ekvcDate{2021-06-20}
\csname ekvc@tmp\endcsname
\expandafter\chardef\csname ekvc@tmp\endcsname=\catcode`\@
\catcode`\@=11
+\def\ekvc@tripledots{...}
\newcount\ekvc@keycount
\let\ekvc@long\ekv@empty
\let\ekvc@any@long\ekv@empty
@@ -150,7 +151,7 @@
\ekvc@keycount=0
\let\ekvc@any@long\ekv@empty
\let\ekvc@initials\ekv@empty
- \ekvparse\ekvc@err@value@required\ekvc@SetupSplitKeys@a
+ \ekvparse\ekvc@SetupSplitKeys@check@unknown\ekvc@SetupSplitKeys@a
}
\protected\def\ekvc@SetupSplitKeys@a#1%
{%
@@ -202,12 +203,40 @@
{\expandafter\ekvc@setup@splitmacro\expandafter{\the\ekvc@keycount}}%
{}%
}
+\protected\long\def\ekvc@SetupSplitKeys@check@unknown#1%
+ {%
+ \begingroup
+ \edef\ekvc@tmp{\detokenize{#1}}%
+ \expandafter
+ \endgroup
+ \ifx\ekvc@tripledots\ekvc@tmp
+ \advance\ekvc@keycount1
+ \begingroup\expandafter\endgroup
+ \expandafter\ekvc@SetupSplitKeys@unknown
+ \csname ekvc@splitmark@\the\ekvc@keycount\endcsname
+ \let\ekvc@any@long\long
+ \else
+ \ekvc@err@value@required{#1}%
+ \fi
+ }
+\protected\long\def\ekvc@SetupSplitKeys@unknown#1%
+ {%
+ \long\expandafter\def\csname\ekv@name\ekvc@set{}u\endcsname##1##2##3#1##4%
+ {##3#1{##4,##2= {##1} }}%
+ \long\expandafter\def\csname\ekv@name\ekvc@set{}uN\endcsname##1##2#1##3%
+ {##2#1{##3,##1}}%
+ \edef\ekvc@initials{\unexpanded\expandafter{\ekvc@initials#1{}}}%
+ \ekvc@helpers@needed
+ {\expandafter\ekvc@setup@splitmacro\expandafter{\the\ekvc@keycount}}%
+ {}%
+ }
\protected\def\ekvc@split@p@long
{%
\let\ekvc@long\long
\let\ekvc@any@long\long
\ekvc@SetupSplitKeys@c
}
+\def\ekvc@split@p@short{\ekvc@SetupSplitKeys@c}
\protected\def\ekvc@defarggobbler#1{\def\ekvc@tmp##1#1##2##{##1#1}}
\begingroup
\edef\ekvc@tmp
@@ -340,7 +369,7 @@
{%
\let\ekvc@any@long\ekv@empty
\let\ekvc@initials\ekv@empty
- \ekvparse\ekvc@err@value@required\ekvc@SetupHashKeys@a{#1}%
+ \ekvparse\ekvc@SetupHashKeys@check@unknown\ekvc@SetupHashKeys@a{#1}%
}
\protected\def\ekvc@SetupHashKeys@a#1%
{%
@@ -386,12 +415,42 @@
\ekvlet\ekvc@set{#1}\ekvc@tmp
\ekvc@setup@hashmacro{#1}%
}
+\protected\long\def\ekvc@SetupHashKeys@check@unknown#1%
+ {%
+ \begingroup
+ \edef\ekvc@tmp{\detokenize{#1}}%
+ \expandafter
+ \endgroup
+ \ifx\ekvc@tripledots\ekvc@tmp
+ \ekvc@SetupHashKeys@unknown
+ \let\ekvc@any@long\long
+ \else
+ \ekvc@err@value@required{#1}%
+ \fi
+ }
+\def\ekvc@SetupHashKeys@unknown#1%
+ {%
+ \protected\def\ekvc@SetupHashKeys@unknown
+ {%
+ \expandafter
+ \let\csname\ekv@name\ekvc@set{}u\endcsname\ekvc@hash@unknown@kv
+ \expandafter
+ \let\csname\ekv@name\ekvc@set{}uN\endcsname\ekvc@hash@unknown@k
+ \edef\ekvc@initials{\unexpanded\expandafter{\ekvc@initials#1{}}}%
+ \ekvc@setup@hashmacro{...}%
+ }%
+ \long\def\ekvc@hash@unknown@kv##1##2##3#1##4{##3#1{##4,##2= {##1} }}%
+ \long\def\ekvc@hash@unknown@k##1##2#1##3{##2#1{##3,##1}}%
+ }
+\expandafter\ekvc@SetupHashKeys@unknown
+ \csname ekvc@hashmark@\ekvc@tripledots\endcsname
\protected\def\ekvc@hash@p@long
{%
\let\ekvc@long\long
\let\ekvc@any@long\long
\ekvc@SetupHashKeys@c
}
+\def\ekvc@hash@p@short{\ekvc@SetupHashKeys@c}
\protected\def\ekvc@setup@hashmacro#1%
{%
\ekv@ifdefined{ekvc@fasthash@#1}{}%
@@ -432,18 +491,19 @@
\unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}%
####2####3\unexpanded{\ekvc@stop}####4%
{%
- ####4{####1####3}{####2}%
+ ####4{####2}%
}%
\long\gdef\unexpanded\expandafter
{\csname ekvc@safesplithash@#1\endcsname}####1%
{%
\unexpanded\expandafter
{\csname ekvc@@safesplithash@#1\endcsname}%
- ####1\unexpanded{\ekvc@mark\ekvc@safe@found@hash}%
+ ####1\unexpanded{\ekvc@mark\ekvc@safe@after@hash}%
\unexpanded\expandafter
{%
\csname ekvc@hashmark@#1\endcsname{}%
- \ekvc@mark{\ekvc@err@missing@hash{#1}\ekvc@safe@no@hash}%
+ \ekvc@mark
+ {\ekvc@err@missing@hash{#1}\ekvc@safe@after@hash}%
\ekvc@stop
}%
}%
@@ -454,7 +514,7 @@
####2####3\unexpanded{\ekvc@mark}####4####5%
\unexpanded{\ekvc@stop}%
{%
- ####4{####2}####1####3\unexpanded{\ekvc@stop}%
+ ####4{####2}%
}%
}%
\ekvc@tmp
@@ -475,26 +535,17 @@
{\csname ekvc@safesplithash@#1\endcsname}%
{\ekvc@err@unknown@hash{#1}\ekvcValueSplit@recover}%
}
-\long\def\ekvcValueSplit@recover#1#2%
+\long\def\ekvcValueSplit@recover#1#2{#2{}}
+\long\def\ekvc@safe@after@hash#1#2%
{%
- #2{#1}{}%
- }
-\long\def\ekvc@safe@found@hash#1#2\ekvc@stop#3%
- {%
- #3{#2}{#1}%
- }
-\long\def\ekvc@safe@no@hash#1#2\ekvc@mark\ekvc@safe@found@hash\ekvc@stop#3%
- {%
- #3{#2}{}%
+ #2{#1}%
}
\long\def\ekvcValueSplitFast#1#2%
- {%
- \csname ekvc@fastsplithash@#1\endcsname#2\ekvc@stop
- }
+ {\csname ekvc@fastsplithash@#1\endcsname#2\ekvc@stop}
\long\def\ekvc@safehash@#1{\ekvc@err@empty@hash{}}
\long\def\ekvc@fasthash@#1\ekvc@stop{\ekvc@err@empty@hash}
-\long\def\ekvc@safesplithash@#1#2{\ekvc@err@empty@hash#2{#1}{}}
-\long\def\ekvc@fastsplithash@#1\ekvc@stop#2{\ekvc@err@empty@hash#2{#1}{}}
+\long\def\ekvc@safesplithash@#1#2{\ekvc@err@empty@hash#2{}}
+\long\def\ekvc@fastsplithash@#1\ekvc@stop#2{\ekvc@err@empty@hash#2{}}
\protected\long\def\ekvcSecondaryKeys#1#2%
{%
\edef\ekvc@set{\string#1}%
@@ -518,6 +569,56 @@
}%
{#2}%
}
+\protected\long\def\ekvcChange#1%
+ {%
+ \ekvifdefinedset{\string#1}%
+ {%
+ \ekvc@ifdefined#1%
+ {\ekvc@change#1}%
+ {\ekvc@err@no@key@macro#1\@gobble}%
+ }%
+ {\ekvc@err@no@key@macro#1\@gobble}%
+ }
+\protected\def\ekvc@change#1%
+ {\expandafter\ekvc@change@a\meaning#1\ekv@stop#1}
+\def\ekvc@change@a#1%
+ {%
+ \protected\def\ekvc@change@a##1#1##2->##3\ekv@stop
+ {%
+ \ekvc@change@iflong{##1}%
+ {\ekvc@change@b{}}%
+ {\ekvc@change@b{\long}}%
+ }%
+ }
+\expandafter\ekvc@change@a\expandafter{\detokenize{macro:}}
+\protected\def\ekvc@change@b#1#2%
+ {\expandafter\ekvc@change@c\expandafter{#2{##1}}{#1}#2}
+\ekv@exparg{\protected\long\def\ekvc@change@c#1#2#3#4}%
+ {%
+ \expandafter\iffalse\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
+ }
+\def\ekvc@change@iflong#1%
+ {%
+ \protected\def\ekvc@change@iflong##1%
+ {\expandafter\ekv@ifempty\expandafter{\ekvc@change@iflong@##1#1}}%
+ \def\ekvc@change@iflong@##1#1{}
+ }
+\expandafter\ekvc@change@iflong\expandafter{\string\long}
+\long\def\ekvcPass#1#2%
+ {%
+ \ekvifdefined{\string#1}{#2}%
+ {\csname\ekv@name{\string#1}{#2}\endcsname}%
+ {\ekvc@err@unknown@key@or@macro{#1}{#2}\@gobble}%
+ }
\protected\def\ekvc@p@long#1%
{%
\ekvc@ifspace{#1}%
@@ -762,11 +863,15 @@
\errmessage
{expkv-cs Error: Unknown key `\unexpanded{#1}' for macro `\ekvc@set'}%
}
+\long\def\ekvc@err@no@key@macro#1%
+ {\errmessage{expkv-cs Error: \string#1 is no key=val macro}}
\ekv@exparg{\long\def\ekvc@err#1}{\ekverr{expkv-cs}{#1}}
\long\def\ekvc@err@unknown@hash#1{\ekvc@err{unknown hash `#1'}}
\long\def\ekvc@err@missing@hash#1{\ekvc@err{hash `#1' not found}}
\long\def\ekvc@err@empty@hash{\ekvc@err{empty hash}}
\def\ekvc@err@invalid@bool#1{\ekvc@err{invalid boolean value `#1'}}
+\long\def\ekvc@err@unknown@key@or@macro#1#2%
+ {\ekvc@err{unknown key `#2' for macro #1}}
\catcode`\@=\ekvc@tmp
%%
%%