summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keyval2e
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-26 22:12:11 +0000
committerKarl Berry <karl@freefriends.org>2011-08-26 22:12:11 +0000
commit84764e76d62d68daac0a00ac53194a2e8bb8562e (patch)
treea274484db1d1a652f6d9cdeed6bbcfb894a54be7 /Master/texmf-dist/tex/latex/keyval2e
parent87fd456b73f50d2b0ff7d2fc0e243d1d2fbdf02c (diff)
keyval2e 0.0.2 (26aug11)
git-svn-id: svn://tug.org/texlive/trunk@23698 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keyval2e')
-rw-r--r--Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty137
1 files changed, 93 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty b/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
index 81e60c3e0c4..6d4769568ea 100644
--- a/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
+++ b/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
@@ -1,6 +1,6 @@
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
% %
-% This is file 'keyval2e.sty', version 0.0.1, July 2011 %
+% This is file 'keyval2e.sty', version 0.0.2, August 2011 %
% %
% This package and accompanying files may be distributed and/or %
% modified under the conditions of the LaTeX Project Public License, %
@@ -24,14 +24,15 @@
\UseNormalCatcodes
\StyleFilePurpose{Lightweight and robust key-value parser (AM)}
\StyleFileRCSInfo
-$Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
+$Id: keyval2e.sty,v 0.0.2 2011/08/24 09:00:00 Ahmed Musa Exp $
\ProvidesPackage{keyval2e}[\StyleFileInfo]
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\SetStyleFileMessages[kve@]{info}{warn}{err}
+\newvariables{count}[kve@]{keydepth}[0]
\robust@def*\kve@parse{\cpt@teststopt\kve@parse@a,}
\robust@def*\kve@parse@a[#1]#2#3{%
+ \kve@ifblank#2\doblank\gobble@to@relax
\cpt@stchoose{cpt@st}{#2}\reserved@e\kve@parse
- \ifx\@empty\reserved@e\begingroup\cpt@defrelax\fi
\pushfunctions\kve@parse
{\ifloopbreak,\kve@do,\kve@act}\cpt@csvdepth
\cpt@sttrue\cpt@csvnormalize[#1]\reserved@e
@@ -48,6 +49,14 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
\expandafter\kve@do\expandafter.\reserved@e#1\cpt@nil#1%
\popfunctions\kve@parse\cpt@csvdepth\cpt@relax
}
+\robust@def*\kve@ifblank#1\doblank#2{%
+ \ifcat$\detokenize\expandafter{\@gobble#1.}$%
+ \expandafter\@iden
+ \else
+ \expandafter\@gobble
+ \fi
+ {#2}%
+}
% \kve@definekeys[<pref>]{<fam>}[<mp>]{keya/defa/callback,...}
\robust@def*\kve@definekeys{%
\begingroup\endlinechar\m@one
@@ -58,53 +67,92 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
\cpt@testopt{\kve@d@f@nekeys{#1}{#2}}{kvmp@}%
}
\robust@def*\kve@d@f@nekeys#1#2[#3]#4{%
- \gletcs\ifcpt@defkeyst\ifcpt@st
+ \gletcs\ifkve@tempsw\ifcpt@st
\endgroup
- \ifx\noindent#4\noindent\begingroup\cpt@defrelax\fi
+ \kve@ifblank#4\doblank\gobble@to@relax
\def\kve@d@f@n@keys##1{%
- \ifcpt@defkeyst
- \newcsndef*{#1@#2@\currkey}####1{%
- \newcsndef*{#3\currkey}{####1}##1\relax
+ \ifkve@tempsw
+ \ifcsndefinable{#1@#2@\currkey}{%
+ \ifcsndefinable{#3\currkey}{}%
+ }%
+ \fi
+ \begingroup
+ \def\kve@true{true}\def\kve@false{false}%
+ \expandafter\endgroup\ifcase\ifx\currval\kve@true0\else
+ \ifx\currval\kve@false0\else1\fi\fi\relax
+ \expandafter\newif\csname if#3\currkey\endcsname
+ \@namedef{#1@#2@\currkey}####1{%
+ \kve@checkbool{####1}{%
+ \usename{#3\currkey####1}%
+ \@namedef{#3\currkey}{####1}##1\relax
+ }{%
+ \kve@keyvalerr
+ }%
}%
\else
- \csndef{#1@#2@\currkey}####1{%
- \csndef{#3\currkey}{####1}##1\relax
+ \@namedef{#1@#2@\currkey}####1{%
+ \@namedef{#3\currkey}{####1}##1\relax
}%
\fi
}%
- \csndef{#1@#2@initialkeyvals}{}%
- \def\kve@splita##1/{\def\currkey{##1}\kve@splitb.}%
+ \@namedef{#1@#2@initialkeyvals}{}%
+ \def\kve@tempc{^?}%
+ \def\kve@splita##1/{%
+ \edef\currkey{\cpttrimspaces{##1}}%
+ \kve@splitb.%
+ }%
\def\kve@splitb##1/##2/##3\kve@nil{%
- \edef\currval{\unexpanded\expandafter{\@gobble##1}}%
- \csnedef{#1@#2@\currkey @default}{%
- \cptmakecs{#1@#2@\currkey}{\expandcsonce\currval}%
- }%
- \kve@d@f@n@keys{##2}%
+ \edef\currval{\expandafter\cpttrimspaces\expandafter{\@gobble##1}}%
+ \ifx\currval\kve@tempc
+ \def\currval{}%
+ \else
+ \expandafter\edef\csname#1@#2@\currkey @default\endcsname{%
+ \cptmakecs{#1@#2@\currkey}{\expandcsonce\currval}%
+ }%
+ \fi
+ \edef\kve@tempb{\unexpanded{##2}}%
+ \ifx\kve@tempb\kve@tempc\def\kve@tempb{}\fi
+ \expandafter\kve@d@f@n@keys\expandafter{\kve@tempb}%
\letcstocsn\kve@tempa{#1@#2@initialkeyvals}%
- \csnedef{#1@#2@initialkeyvals}{%
+ \expandafter\edef\csname#1@#2@initialkeyvals\endcsname{%
\cptliststack,\kve@tempa\currkey=%
\oifstrcmpTF\currval{true}{false}{\expandcsonce\currval}%
}%
}%
- \kve@parse{#4}{\kve@splita##1///\kve@nil}%
+ \kve@parse{#4}{\kve@splita##1/^?/^?/\kve@nil}%
\kve@setdefaults[#1]{#2}[]\cpt@relax
}
% \kve@setkeys[pref]{<fam>}[na]{<keyval>}
\robust@def*\kve@setkeys{\cpt@testopt\kve@setkeys@a{KV}}
\robust@def*\kve@setkeys@a[#1]#2{\cpt@testopt{\kve@setkeys@b{#1}{#2}}{}}
\robust@def*\kve@setkeys@b#1#2[#3]#4{%
- \ifx\noindent#4\noindent\begingroup\cpt@defrelax\fi
+ \kve@ifblank#4\doblank\gobble@to@relax
+ \ifnum\kve@keydepth>4\relax
+ \kve@err{Maximum re-entrance limit of 4 exceeded
+ \MsgBrk by \string\kve@setkeys}\@ehc
+ \fi
\pushfunctions\kve@setkeys{\currpref,\currfam,\currkey,%
\currval,\currkeyval}\kve@keydepth
\def\currpref{#1}\def\currfam{#2}%
\edef\kve@na{\cptcommanormalize{#3}}%
- \def\kve@splita##1={\def\currkey{##1}\kve@splitb.}%
+ \def\kve@splita##1={%
+ \def\currkey{##1}%
+ \kve@splitb.%
+ }%
\def\kve@splitb##1=##2\kve@nil{%
+ \cpt@swafalse
+ \kve@ifblank##2\doblank{%
+ \ifcsndefTF{#1@#2@\currkey @default}{%
+ \cpt@swatrue
+ }{%
+ \kve@err{No user value and no default value
+ \MsgBrk for key '\currkey'}\@ehc
+ }%
+ }%
\edef\currval{\unexpanded\expandafter{\@gobble##1}}%
\edef\currkeyval{\expandcsonce\currkey=\expandcsonce\currval}%
\xifinsetTF{,\cptoxdetok\currkey,}{,\cptoxdetok\kve@na,}
- {}
- {\kve@setkeys@c{#1}{#2}}%
+ {}{\kve@setkeys@c{#1}{#2}}%
}%
\cpt@stfalse\cpt@kvnormalize[,]{#4}%
\kve@parse*\normalized@list{\kve@splita##1==\kve@nil}%
@@ -113,12 +161,12 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
}
\robust@def*\kve@setkeys@c#1#2{%
\ifcsndefTF{#1@#2@\currkey}{%
- \ifcsemptyTF\currval{%
+ \ifcpt@swa
\begingroup
- \csndef{#1@#2@\currkey}##1{\toks@{\def\currval{##1}}}%
+ \@namedef{#1@#2@\currkey}##1{\toks@{\def\currval{##1}}}%
\csname#1@#2@\currkey @default\endcsname
\expandafter\endgroup\the\toks@
- }{}%
+ \fi
\csname#1@#2@\currkey\expandafter
\endcsname\expandafter{\currval}\relax
}{%
@@ -128,17 +176,16 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
}
\robust@def*\kve@getkeynames#1{%
\def\kve@keynames{}%
- \ifblankTF{#1}{}{%
- \begingroup
- \cpt@stfalse\cpt@kvnormalize[,]{#1}%
- \def\kve@g@tkeynames##1=##2\kve@nil{%
- \edef\kve@keynames{%
- \cptliststack,\kve@keynames\cpttrimspaces{##1}%
- }%
+ \kve@ifblank#1\doblank\gobble@to@relax
+ \begingroup
+ \cpt@stfalse\cpt@kvnormalize[,]{#1}%
+ \def\kve@g@tkeynames##1=##2\kve@nil{%
+ \edef\kve@keynames{%
+ \cptliststack,\kve@keynames\cpttrimspaces{##1}%
}%
- \kve@parse*\normalized@list{\kve@g@tkeynames##1=\kve@nil}%
- \postgroupdef\kve@keynames\endgroup
}%
+ \kve@parse*\normalized@list{\kve@g@tkeynames##1=\kve@nil}%
+ \postgroupdef\kve@keynames\endgroup\cpt@relax
}
% \kve@setdefaults[<pref>]{<fam>}[<na>]
\robust@def*\kve@setdefaults{\cpt@testopt\kve@s@tdefaults{KV}}
@@ -157,7 +204,7 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
{No initial key-value pairs saved for '#1,#2'.}%
}%
}
-% \kve@setafterdefaults[<pref>]{<fam>}[<na>]{<curr-keyval>}
+% \kve@setafterdefaults[<pref>]{<fam>}[<na>]{<keyval>}
\robust@def*\kve@setafterdefaults{%
\cpt@testopt\kve@s@tafterdefaults{KV}%
}
@@ -165,7 +212,7 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
\cpt@testopt{\kve@s@taft@rdefaults{#1}{#2}}{}%
}
\robust@def*\kve@s@taft@rdefaults#1#2[#3]#4{%
- \ifx\noindent#4\noindent\begingroup\cpt@defrelax\fi
+ \kve@ifblank#4\doblank\gobble@to@relax
\kve@getkeynames{#4}%
\letcstocsn\kve@tempa{#1@#2@initialkeyvals}%
\ifdefTF\kve@tempa{%
@@ -204,17 +251,19 @@ $Id: keyval2e.sty,v 0.0.1 2011/08/11 09:00:00 Ahmed Musa Exp $
}
\robust@def*\kve@checkchoice#1#2#3{%
\expandafter\cptswapfirstbraced\expandafter
- {\romannumeral-`\q\cpttrimspace{#1}}
+ {\romannumeral-`\q\cpttrimspaces{#1}}
{\kve@ch@ckchoice#2,\cpt@mil:\cpt@mil,\cpt@nil}{#3}%
}
\robust@def*\kve@ch@ckchoice#1:#2,#3\cpt@nil#4#5{%
- \ifblankTF{#3}{\unexpanded{#5}}{%
- \xifstrcmpTF{\cpttrimspaces{#1}}{\unexpanded{#4}}{%
- \unexpanded{#2}%
- }{%
- \kve@ch@ckchoice#3\cpt@nil{#4}{#5}%
- }%
+ \kve@ifblank#3\doblank{%
+ \unexpanded{#5}\gobble@to@relax
}%
+ \xifstrcmpTF{\cpttrimspaces{#1}}{\unexpanded{#4}}{%
+ \unexpanded{#2}%
+ }{%
+ \kve@ch@ckchoice#3\cpt@nil{#4}{#5}%
+ }%
+ \cpt@relax
}
\endinput \ No newline at end of file