summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-14 22:34:31 +0000
committerKarl Berry <karl@freefriends.org>2011-08-14 22:34:31 +0000
commita7f0da2c8733aa5d43b841b8a182866586a0d4d7 (patch)
tree4c469b9d7470ee616e0d1ec1bf7427b368184417 /Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
parent88fd8de78d44334a3f3a61d825b2053a688fb687 (diff)
new latex package keyval2e (14aug11)
git-svn-id: svn://tug.org/texlive/trunk@23551 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty')
-rw-r--r--Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty196
1 files changed, 196 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty b/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
new file mode 100644
index 00000000000..36dbbe3786c
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/keyval2e/keyval2e.sty
@@ -0,0 +1,196 @@
+%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
+% %
+% This is file 'keyval2e.sty', version 0.0.1, July 2011 %
+% %
+% This package and accompanying files may be distributed and/or %
+% modified under the conditions of the LaTeX Project Public License, %
+% either version 1.3 of this license or any later version. The latest %
+% version of this license is in http://www.latex-project.org/lppl.txt %
+% and version 1.3 or later is part of all distributions of LaTeX %
+% version 2005/12/01 or later. %
+% %
+% The LPPL maintenance status of this software is 'author-maintained'. %
+% %
+% This software is provided 'as it is', without warranty of any kind, %
+% either expressed or implied, including, but not limited to, the %
+% implied warranties of merchantability and fitness for a particular %
+% purpose. %
+% %
+% Copyright (c) 2011 Ahmed Musa (a.musa@rocketmail.com). %
+% %
+%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
+
+\@ifpackageloaded{catoptions}{}{\RequirePackage{catoptions}[2011/07/20]}
+\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 $
+\ProvidesPackage{keyval2e}[\StyleFileInfo]
+\NeedsTeXFormat{LaTeX2e}[1996/12/01]
+\SetStyleFileMessages[kve@]{info}{warn}{err}
+\robust@def*\kve@parse{\cpt@testopt\kve@parse@a,}
+\robust@def*\kve@parse@a[#1]#2#3{%
+ \pushfunctions\kve@parse{\ifloopbreak,\kve@do,\kve@act}\cpt@csvdepth
+ \cpt@stfalse\cpt@csvnormalize[#1]{#2}%
+ \def\kve@act##1{#3}%
+ \def\kve@do##1#1{%
+ \edef\reserved@a{\unexpanded\expandafter{\@gobble##1}}%
+ \ifxTF\reserved@a\cpt@nnil{}{%
+ \expandafter\kve@act\expandafter{\reserved@a}\relax
+ \@nameuse{@\ifloopbreak second\else first\fi oftwo}%
+ {\kve@do.}{\gobble@to@sentinel\cpt@nil#1}%
+ }%
+ }%
+ \loopbreakfalse
+ \ifcsemptyTF\normalized@list{}{%
+ \expandafter\kve@do\expandafter.\normalized@list#1\cpt@nil#1%
+ }%
+ \popfunctions\kve@parse\cpt@csvdepth
+}
+% \kve@definekeys[<KV>]{<fam>}{<keya/defa/callback, ...>}
+\robust@def*\kve@definekeys{\cpt@testopt\kve@d@finekeys{KV}}
+\newletcs\kve@definekey\kve@definekeys
+\robust@def*\kve@d@finekeys[#1]#2#3{%
+ \def\kve@rsvda##1{\csn@def{#1@#2@\currkey}####1{##1}}%
+ \csn@def{#1@#2@initialkeyvals}{}%
+ \def\kve@splita##1/{\def\currkey{##1}\kve@splitb.}%
+ \def\kve@splitb##1/##2/##3\kve@nil{%
+ \edef\currval{\unexpanded\expandafter{\@gobble##1}}%
+ \csn@edef{#1@#2@\currkey @default}{%
+ \cptmakecs{#1@#2@\currkey}{\expandcsonce\currval}%
+ }%
+ \kve@rsvda{##2}%
+ \letcstocsn\kve@tempa{#1@#2@initialkeyvals}%
+ \csn@edef{#1@#2@initialkeyvals}{%
+ \cptliststack,\kve@tempa\currkey=%
+ \oifstrcmpTF\currval{true}{false}{\expandcsonce\currval}%
+ }%
+ }%
+ \kve@parse{#3}{\kve@splita##1///\kve@nil}%
+}
+% \kve@setkeys[<KV>]{<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{%
+ \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@splitb##1=##2\kve@nil{%
+ \edef\currval{\unexpanded\expandafter{\@gobble##1}}%
+ \edef\currkeyval{\expandcsonce\currkey=\expandcsonce\currval}%
+ \xifinsetTF{,\cptoxdetok\currkey,}{,\cptoxdetok\kve@na,}
+ {}
+ {\kve@setkeys@c{#1}{#2}}%
+ }%
+ \cpt@stfalse\cpt@kvnormalize[,]{#4}%
+ \expandafter\kve@parse\expandafter
+ {\normalized@list}{\kve@splita##1==\kve@nil}%
+ \popfunctions\kve@setkeys\kve@keydepth
+}
+\robust@def*\kve@setkeys@c#1#2{%
+ \ifcsndefTF{#1@#2@\currkey}{%
+ \ifcsemptyTF\currval{%
+ \begingroup
+ \csn@def{#1@#2@\currkey}##1{\toks@{\def\currval{##1}}}%
+ \csname#1@#2@\currkey @default\endcsname
+ \expandafter\endgroup\the\toks@
+ }{}%
+ \csname#1@#2@\currkey\expandafter
+ \endcsname\expandafter{\currval}\relax
+ }{%
+ \kve@err{Key '\currkey' not defined}
+ {Key '\currpref,\currfam,\currkey' is undefined}%
+ }%
+}
+\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}%
+ }%
+ }%
+ \expandafter\kve@parse\expandafter
+ {\normalized@list}{\kve@g@tkeynames##1=\kve@nil}%
+ \postgroupdef\kve@keynames\endgroup
+ }%
+}
+% \kve@setdefaults[<KV>]{<fam>}[<na>]
+\robust@def*\kve@setdefaults{\cpt@testopt\kve@s@tdefaults{KV}}
+\robust@def*\kve@s@tdefaults[#1]#2{%
+ \cpt@testopt{\kve@s@td@faults{#1}{#2}}{}%
+}
+\robust@def*\kve@s@td@faults#1#2[#3]{%
+ \ifcsndefTF{#1@#2@initialkeyvals}{%
+ \cptexpanded{%
+ \kve@setkeys[#1]{#2}[#3]
+ {\expandcsnonce{#1@#2@initialkeyvals}}%
+ }%
+ }{%
+ \kve@err{No initial key values for family '#2'}
+ {No initial key-value pairs saved for '#1,#2'.}%
+ }%
+}
+% \kve@setafterdefaults[<KV>]{<fam>}[<na>]{<curr-keyval>}
+\robust@def*\kve@setafterdefaults{%
+ \cpt@testopt\kve@s@tafterdefaults{KV}%
+}
+\robust@def*\kve@s@tafterdefaults[#1]#2{%
+ \cpt@testopt{\kve@s@taft@rdefaults{#1}{#2}}{}%
+}
+\robust@def*\kve@s@taft@rdefaults#1#2[#3]#4{%
+ \kve@getkeynames{#4}%
+ \letcstocsn\kve@tempa{#1@#2@initialkeyvals}%
+ \ifdefTF\kve@tempa{%
+ \cptexpanded{%
+ \kve@setkeys[#1]{#2}[\kve@keynames,#3]
+ {\expandcsonce\kve@tempa}%
+ \kve@setkeys[#1]{#2}[#3]{\unexpanded{#4}}%
+ }%
+ }{%
+ \kve@err{No initial key values for family '#2'}
+ {No initial key-value pairs saved for '#1,#2'.}%
+ }%
+}
+\robust@def*\kve@keyvalerr{%
+ \kve@getinnoval*[10]\currval
+ \kve@err{Invalid value '\innoval' for key '\currkey'}
+ {Key '\currkey' has an inadmissible value '\innoval'.}%
+}
+\robust@def*\kve@getinnoval{\cpt@teststopt\kve@g@tinnoval{10}}
+\robust@def*\kve@g@tinnoval[#1]#2{%
+ \begingroup
+ \def\innoval{}\@tempcnta\z@pt
+ \def\siso@do##1{%
+ \advance\@tempcnta by1
+ \ifnum\@tempcnta<#1\relax\edef\innoval{\innoval##1}\fi
+ }%
+ \cptexpandarg\siso@@loop
+ {\if@boolTF{cpt@st}\cptoxdetok\detokenize{#2}}%
+ \edef\innoval{\innoval\ifnum\@tempcnta>#1\string\ETC\fi}%
+ \postgroupdef\innoval\endgroup
+}
+\robust@def*\kve@checkbool#1#2#3{%
+ \lowercase{\xifinsetTF{,\cpttrimspaces{#1},}}
+ {,true,false,}{#2}{#3}%
+}
+\robust@def*\kve@checkchoice#1#2#3{%
+ \expandafter\cptswapfirstbraced\expandafter
+ {\romannumeral-`\q\cpttrimspace{#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}%
+ }%
+ }%
+}
+
+\endinput \ No newline at end of file