summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-05-02 21:50:45 +0000
committerKarl Berry <karl@freefriends.org>2012-05-02 21:50:45 +0000
commitaa1776c78dfdb456e2228fbceaa886e64e36174c (patch)
tree7967af7f0f2079a632809a813221918af16ba8cc /Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx
parenta86d14742b305868a1c2b1f33f1263a6b7d0e03d (diff)
oberdiek (1may12)
git-svn-id: svn://tug.org/texlive/trunk@26177 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx')
-rw-r--r--Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx497
1 files changed, 451 insertions, 46 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx b/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx
index fb6d8b26895..68dd55834eb 100644
--- a/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx
+++ b/Master/texmf-dist/source/latex/oberdiek/kvsetkeys.dtx
@@ -1,11 +1,12 @@
% \iffalse meta-comment
-%
+%
% File: kvsetkeys.dtx
-% Version: 2011/04/07 v1.13
-%
-% Copyright (C) 2006, 2007, 2009-2011 by
+% Version: 2012/04/25 v1.16
+% Info: Key value parser
+%
+% Copyright (C) 2006, 2007, 2009-2012 by
% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
-%
+%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
@@ -15,24 +16,25 @@
% 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.
-%
+%
% This work has the LPPL maintenance status "maintained".
-%
+%
% This Current Maintainer of this work is Heiko Oberdiek.
-%
+%
% The Base Interpreter refers to any `TeX-Format',
% because some files are installed in TDS:tex/generic//.
-%
+%
% This work consists of the main source file kvsetkeys.dtx
% and the derived files
% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv,
% kvsetkeys-example.tex, kvsetkeys-test1.tex,
-% kvsetkeys-test2.tex, kvsetkeys-test3.tex.
-%
+% kvsetkeys-test2.tex, kvsetkeys-test3.tex,
+% kvsetkeys-test4.tex.
+%
% Distribution:
% CTAN:macros/latex/contrib/oberdiek/kvsetkeys.dtx
% CTAN:macros/latex/contrib/oberdiek/kvsetkeys.pdf
-%
+%
% Unpacking:
% (a) If kvsetkeys.ins is present:
% tex kvsetkeys.ins
@@ -41,7 +43,7 @@
% (c) If you insist on using LaTeX
% latex \let\install=y\input{kvsetkeys.dtx}
% (quote the arguments according to the demands of your shell)
-%
+%
% Documentation:
% (a) If kvsetkeys.drv is present:
% latex kvsetkeys.drv
@@ -51,14 +53,14 @@
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
-%
+%
% Programm calls to get the documentation (example):
% pdflatex kvsetkeys.dtx
% makeindex -s gind.ist kvsetkeys.idx
% pdflatex kvsetkeys.dtx
% makeindex -s gind.ist kvsetkeys.idx
% pdflatex kvsetkeys.dtx
-%
+%
% Installation:
% TDS:tex/generic/oberdiek/kvsetkeys.sty
% TDS:doc/latex/oberdiek/kvsetkeys.pdf
@@ -66,6 +68,7 @@
% TDS:doc/latex/oberdiek/test/kvsetkeys-test1.tex
% TDS:doc/latex/oberdiek/test/kvsetkeys-test2.tex
% TDS:doc/latex/oberdiek/test/kvsetkeys-test3.tex
+% TDS:doc/latex/oberdiek/test/kvsetkeys-test4.tex
% TDS:source/latex/oberdiek/kvsetkeys.dtx
%
%<*ignore>
@@ -83,7 +86,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: kvsetkeys 2011/04/07 v1.13 Key value parser (HO)}
+\Msg{* Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO)}
\Msg{************************************************************************}
\keepsilent
@@ -95,9 +98,9 @@
This is a generated file.
Project: kvsetkeys
-Version: 2011/04/07 v1.13
+Version: 2012/04/25 v1.16
-Copyright (C) 2006, 2007, 2009-2011 by
+Copyright (C) 2006, 2007, 2009-2012 by
Heiko Oberdiek <heiko.oberdiek at googlemail.com>
This work may be distributed and/or modified under the
@@ -121,7 +124,8 @@ This work consists of the main source file kvsetkeys.dtx
and the derived files
kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv,
kvsetkeys-example.tex, kvsetkeys-test1.tex,
- kvsetkeys-test2.tex, kvsetkeys-test3.tex.
+ kvsetkeys-test2.tex, kvsetkeys-test3.tex,
+ kvsetkeys-test4.tex.
\endpreamble
\let\MetaPrefix\DoubleperCent
@@ -137,6 +141,11 @@ and the derived files
\file{kvsetkeys-test1.tex}{\from{kvsetkeys.dtx}{test1}}%
\file{kvsetkeys-test2.tex}{\from{kvsetkeys.dtx}{test2}}%
\file{kvsetkeys-test3.tex}{\from{kvsetkeys.dtx}{test2,noetex}}%
+ \file{kvsetkeys-test4.tex}{\from{kvsetkeys.dtx}{test4}}%
+ \nopreamble
+ \nopostamble
+ \usedir{source/latex/oberdiek/catalogue}%
+ \file{kvsetkeys.xml}{\from{kvsetkeys.dtx}{catalogue}}%
}
\catcode32=13\relax% active space
@@ -163,16 +172,16 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{kvsetkeys.drv}%
- [2011/04/07 v1.13 Key value parser (HO)]%
+ [2012/04/25 v1.16 Key value parser (HO)]%
\documentclass{ltxdoc}
-\usepackage{holtxdoc}[2011/02/04]
+\usepackage{holtxdoc}[2011/11/22]
\begin{document}
\DocInput{kvsetkeys.dtx}%
\end{document}
%</driver>
% \fi
%
-% \CheckSum{1265}
+% \CheckSum{1557}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -193,7 +202,7 @@ and the derived files
% \GetFileInfo{kvsetkeys.drv}
%
% \title{The \xpackage{kvsetkeys} package}
-% \date{2011/04/07 v1.13}
+% \date{2012/04/25 v1.16}
% \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}}
%
% \maketitle
@@ -345,6 +354,18 @@ and the derived files
%
% \subsection{Processing key value pairs}
%
+% Key value pairs can be processed in many different ways.
+% For example, the processor for \cs{kvsetkeys} works similar
+% to \cs{setkeys} of package \xpackage{keyval}. There unknown
+% keys raise an error.
+%
+% Package \xpackage{xkeyval} also knows a star form of \cs{setkeys}
+% that stores unknown keys in an internal macro for further processing
+% with \cs{setrmkeys} and similar macros. This feature is covered
+% by processor \cs{kv@processor@known}.
+%
+% \subsubsection{Processing similar to \xpackage{keyval}}
+%
% \begin{declcs}{kv@processor@default}\,\M{family}\,\M{key}\,\M{value}
% \end{declcs}
% There are many possiblities to process key value pairs.
@@ -357,19 +378,48 @@ and the derived files
% may contain package \xpackage{babel}'s shorthands
% (since 2011/04/07 v1.13).
%
+% Since 2011/10/18 v1.15 the family handler can reject the
+% successful handling of a key by calling \cs{kv@handled@false}.
+%
+% Since 2012/04/25 v1.16 \cs{kv@processor@default} also defines
+% macro \cs{kv@fam} with meaning \meta{family} for convenience.
+%
+% \subsubsection{Processing similar to \cs{setkeys*} of package \xpackage{xkeyval}}
+%
+% \begin{declcs}{kv@processor@known}\,\M{family}\,^^A
+% \M{cmd}\,\M{key}\,\M{value}
+% \end{declcs}
+% The key value processor \cs{kv@processor@known} behaves similar
+% to \cs{kv@processor@default}. If the \meta{key} exists in the
+% \meta{family} its code is called, otherwise the family handler
+% is tried. If the family handler is not set or cannot handle the
+% key, the unknown key value pair is added to the macro \meta{cmd}.
+% Since 2011/10/18 v1.15.
+%
% The behaviour in pseudo code:
% \begin{quote}
% if \meta{key} exists\\
% \hspace*{1.5em}call the keyval code of \meta{key}\\
% else\\
% \hspace*{1.5em}if \meta{handler} for \meta{family} exists\\
+% \hspace*{3em}handled = true\\
% \hspace*{3em}\meta{handler}\,\M{key}\,\M{value}\\
+% \hspace*{3em}if handled\\
+% \hspace*{3em}else\\
+% \hspace*{4.5em}add \texttt{"}\M{key}\texttt{=}\M{value}\texttt{"}
+% to \M{cmd}\\
+% \hspace*{3em}fi\\
% \hspace*{1.5em}else\\
+% \hspace*{3em}add \texttt{"}\M{key}\texttt{=}\M{value}\texttt{"}
+% to \M{cmd}\\
% \hspace*{3em}raise unknown key error\\
% \hspace*{1.5em}fi\\
% fi
% \end{quote}
%
+% Since 2012/04/25 v1.16 \cs{kv@processor@known} also defines
+% macro \cs{kv@fam} with meaning \meta{family} for convenience.
+%
% \subsection{Default family handler}
%
% \cs{kv@processor@default} calls \meta{handler}, the default
@@ -385,17 +435,51 @@ and the derived files
% can be used for the key and the value. If the value is not given,
% \cs{kv@value} has the meaning \cs{relax}.
%
+% \begin{declcs}{kv@unset@family@handler}\,\M{family}
+% \end{declcs}
+% It removes the family handler for \meta{family}.
+% Since 2011/10/18 v1.15.
+%
% \subsection{Put it all together}
%
% \begin{declcs}{kvsetkeys}\,\M{family}\,\M{key value list}
% \end{declcs}
-% The work is done by the previous commands. \cs{kvsetkeys}
-% just calls them:
+% Macro \cs{kvsetkeys} processes the \meta{key value list} with
+% the standard processor \cs{kv@processor@default}:
% \begin{quote}
% \cs{kv@parse}\,\M{key value list}^^A
% \texttt{\{}\cs{kv@processor@default}\,\M{family}\texttt{\}}
% \end{quote}
%
+% \begin{declcs}{kvsetknownkeys}\,\M{family}\,\M{cmd}\,\M{key value list}
+% \end{declcs}
+% Macro \cs{kvsetknownkeys} processes the \meta{key value list}
+% with processor \cs{kv@processor@known}. All key value pairs
+% with keys that are not known in \meta{family} are stored
+% in macro \meta{cmd}. A previous contents of macro \meta{cmd}
+% will be overwritten. If all keys can be handled, \meta{cmd}
+% will be empty, otherwise it contains a key value list of
+% unhandled key value pairs.
+% Since 2011/10/18 v1.15.
+%
+% Pseudo code:
+% \begin{quote}
+% create macro \meta{cmdaux} with unique name (inside the current group)\\
+% \cs{def}\meta{cmdaux}\{\}\\
+% \cs{kv@parse}\,\M{key value list}^^A
+% \texttt{\{}\cs{kv@processor@known}\,\M{family}\,\M{cmdaux}\texttt{\}}\\
+% \cs{let}\meta{cmd}=\meta{cmdaux}
+% \end{quote}
+%
+% \begin{declcs}{kvsetkeys@expandafter}\,\M{family}\,\M{list cmd}\\
+% \cs{kvsetknownkeys@expandafter}\,\M{family}\,%
+% \M{cmd}\,\M{list cmd}
+% \end{declcs}
+% Both macros behave like the counterparts without suffix
+% |@expandafter|. The difference is that the key value list is
+% given as macro that is expanded once.
+% Since 2011/10/18 v1.15.
+%
% Thus you can replace \cs{setkeys} of package \xpackage{keyval}
% by the key value parser of this package:
% \begin{quote}
@@ -573,7 +657,7 @@ and the derived files
\fi
\expandafter\x\csname ver@kvsetkeys.sty\endcsname
\ProvidesPackage{kvsetkeys}%
- [2011/04/07 v1.13 Key value parser (HO)]%
+ [2012/04/25 v1.16 Key value parser (HO)]%
% \end{macrocode}
%
% \begin{macrocode}
@@ -612,7 +696,9 @@ and the derived files
\TMP@EnsureCode{36}{3}% $
\TMP@EnsureCode{38}{4}% &
\TMP@EnsureCode{39}{12}% '
+\TMP@EnsureCode{43}{12}% +
\TMP@EnsureCode{44}{12}% ,
+\TMP@EnsureCode{45}{12}% -
\TMP@EnsureCode{46}{12}% .
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{91}{12}% [
@@ -713,11 +799,11 @@ $ \expandafter\endgroup
\begingroup
\toks@{,#1,}%
\KVS@Comma
- \KVS@SpaceComma{ }%
+ \KVS@SpaceComma
\KVS@CommaSpace
\KVS@CommaComma
\KVS@Equals
- \KVS@SpaceEquals{ }%
+ \KVS@SpaceEquals
\KVS@EqualsSpace
\xdef\KVS@Global{\the\toks@}%
\endgroup
@@ -731,7 +817,7 @@ $ \expandafter\endgroup
\begingroup
\toks@{,#1,}%
\KVS@Comma
- \KVS@SpaceComma{ }%
+ \KVS@SpaceComma
\KVS@CommaSpace
\KVS@CommaComma
\xdef\KVS@Global{\the\toks@}%
@@ -766,9 +852,12 @@ $ \expandafter\endgroup
% \begin{macro}{\KVS@SpaceComma}
% Removes spaces before the comma, may add commas at the end.
% \begin{macrocode}
-\long\def\KVS@SpaceComma#1{%
- \expandafter\KVS@@SpaceComma\the\toks@#1,\KVS@Nil
+\def\KVS@SpaceComma#1{%
+ \def\KVS@SpaceComma{%
+ \expandafter\KVS@@SpaceComma\the\toks@#1,\KVS@Nil
+ }%
}
+\KVS@SpaceComma{ }
% \end{macrocode}
% \end{macro}
% \begin{macro}{\KVS@@SpaceComma}
@@ -777,8 +866,7 @@ $ \expandafter\endgroup
\KVS@IfEmpty{#2}{%
\toks@{#1}%
}{%
- \toks@{#1,#2}%
- \expandafter\KVS@@SpaceComma\the\toks@\KVS@Nil
+ \KVS@@SpaceComma#1,#2\KVS@Nil
}%
}
% \end{macrocode}
@@ -797,8 +885,7 @@ $ \expandafter\endgroup
\KVS@IfEmpty{#2}{%
\toks@{#1}%
}{%
- \toks@{#1,#2}%
- \expandafter\KVS@@CommaSpace\the\toks@\KVS@Nil
+ \KVS@@CommaSpace#1,#2\KVS@Nil
}%
}
% \end{macrocode}
@@ -814,10 +901,10 @@ $ \expandafter\endgroup
% \begin{macro}{\KVS@@CommaComma}
% \begin{macrocode}
\long\def\KVS@@CommaComma#1,,#2\KVS@Nil{%
- \toks@{#1,#2}%
\KVS@IfEmpty{#2}{%
+ \toks@{#1,}% (!)
}{%
- \expandafter\KVS@@CommaComma\the\toks@\KVS@Nil
+ \KVS@@CommaComma#1,#2\KVS@Nil
}%
}
% \end{macrocode}
@@ -857,9 +944,12 @@ $ \expandafter\endgroup
% \begin{macro}{\KVS@SpaceEquals}
% Removes spaces before the equals sign.
% \begin{macrocode}
-\long\def\KVS@SpaceEquals#1{%
- \expandafter\KVS@@SpaceEquals\the\toks@#1=\KVS@Nil
+\def\KVS@SpaceEquals#1{%
+ \def\KVS@SpaceEquals{%
+ \expandafter\KVS@@SpaceEquals\the\toks@#1=\KVS@Nil
+ }%
}
+\KVS@SpaceEquals{ }
% \end{macrocode}
% \end{macro}
% \begin{macro}{\KVS@@SpaceEquals}
@@ -868,8 +958,7 @@ $ \expandafter\endgroup
\KVS@IfEmpty{#2}{%
\toks@{#1}%
}{%
- \toks@{#1=#2}%
- \expandafter\KVS@@SpaceEquals\the\toks@\KVS@Nil
+ \KVS@@SpaceEquals#1=#2\KVS@Nil
}%
}
% \end{macrocode}
@@ -888,8 +977,7 @@ $ \expandafter\endgroup
\KVS@IfEmpty{#2}{%
\toks@{#1}%
}{%
- \toks@{#1=#2}%
- \expandafter\KVS@@EqualsSpace\the\toks@\KVS@Nil
+ \KVS@@EqualsSpace#1=#2\KVS@Nil
}%
}
% \end{macrocode}
@@ -1034,6 +1122,30 @@ $ \let\kv@value\KVS@Global
%
% \subsection{Processing key value pairs}
%
+% \begin{macro}{\kv@handled@false}
+% The handler can call \cs{kv@handled@false} or
+% \cs{kv@handled@true} so report failure or success.
+% The default is success (compatibility for versions
+% before 2011/10/18 v1.15).
+% \begin{macrocode}
+\def\kv@handled@false{%
+ \let\ifkv@handled@\iffalse
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\kv@handled@true}
+% \begin{macrocode}
+\def\kv@handled@true{%
+ \let\ifkv@handled@\iftrue
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ifkv@handled@}
+% \begin{macrocode}
+\kv@handled@true
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\kv@processor@default}
% \begin{macrocode}
\def\kv@processor@default#1#2{%
@@ -1050,6 +1162,7 @@ $ \let\kv@value\KVS@Global
% \begin{macro}{\KVS@ProcessorDefault}
% \begin{macrocode}
\long\def\KVS@ProcessorDefault#1#2#3{%
+ \def\kv@fam{#1}%
& \unless\ifcsname KV@#1@#2\endcsname
$ \begingroup\expandafter\expandafter\expandafter\endgroup
$ \expandafter\ifx\csname KV@#1@#2\endcsname\relax
@@ -1058,8 +1171,13 @@ $ \begingroup\expandafter\expandafter\expandafter\endgroup
$ \expandafter\ifx\csname KVS@#1@handler\endcsname\relax
\kv@error@unknownkey{#1}{#2}%
\else
+ \kv@handled@true
\csname KVS@#1@handler\endcsname{#2}{#3}%
\relax
+ \ifkv@handled@
+ \else
+ \kv@error@unknownkey{#1}{#2}%
+ \fi
\fi
\else
\ifx\kv@value\relax
@@ -1079,6 +1197,79 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\kv@processor@known}
+% \begin{macrocode}
+\def\kv@processor@known#1#2#3{%
+ \begingroup
+ \csname @safe@activestrue\endcsname
+ \let\ifincsname\iftrue
+ \edef\KVS@temp{\endgroup
+ \noexpand\KVS@ProcessorKnown{#1}\noexpand#2{#3}%
+ }%
+ \KVS@temp
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\KVS@ProcessorKnown}
+% \begin{macrocode}
+\long\def\KVS@ProcessorKnown#1#2#3#4{%
+ \def\kv@fam{#1}%
+& \unless\ifcsname KV@#1@#3\endcsname
+$ \begingroup\expandafter\expandafter\expandafter\endgroup
+$ \expandafter\ifx\csname KV@#1@#3\endcsname\relax
+& \unless\ifcsname KVS@#1@handler\endcsname
+$ \begingroup\expandafter\expandafter\expandafter\endgroup
+$ \expandafter\ifx\csname KVS@#1@handler\endcsname\relax
+ \KVS@AddUnhandled#2{#3}{#4}%
+ \else
+ \kv@handled@true
+ \csname KVS@#1@handler\endcsname{#3}{#4}%
+ \relax
+ \ifkv@handled@
+ \else
+ \KVS@AddUnhandled#2{#3}{#4}%
+ \fi
+ \fi
+ \else
+ \ifx\kv@value\relax
+& \unless\ifcsname KV@#1@#2@default\endcsname
+$ \begingroup\expandafter\expandafter\expandafter\endgroup
+$ \expandafter\ifx\csname KV@#1@#3@default\endcsname\relax
+ \kv@error@novalue{#1}{#3}%
+ \else
+ \csname KV@#1@#3@default\endcsname
+ \relax
+ \fi
+ \else
+ \csname KV@#1@#3\endcsname{#4}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\KVS@AddUnhandled}
+% \begin{macrocode}
+\long\def\KVS@AddUnhandled#1#2#3{%
+& \edef#1{%
+& \ifx#1\KVS@empty
+& \else
+& \etex@unexpanded{#1},%
+& \fi
+& \etex@unexpanded{{#2}={#3}}%
+& }%
+$ \begingroup
+$ \ifx#1\KVS@empty
+$ \toks@{{#2}={#3}}%
+$ \else
+$ \toks@\expandafter{#1,{#2}={#3}}%
+$ \fi
+$ \xdef\KVS@Global{\the\toks@}%
+$ \endgroup
+$ \let#1\KVS@Global
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\kv@set@family@handler}
% \begin{macrocode}
\long\def\kv@set@family@handler#1#2{%
@@ -1091,6 +1282,18 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\kv@unset@family@handler}
+% \begin{macrocode}
+\long\def\kv@unset@family@handler#1#2{%
+ \begingroup
+ \csname @safe@activestrue\endcsname
+ \let\ifincsname\iftrue
+ \expandafter\endgroup
+ \expandafter\let\csname KVS@#1@handler\endcsname\@UnDeFiNeD
+}
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Error handling}
%
% \begin{macro}{\kv@error@novalue}
@@ -1132,6 +1335,85 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\kvsetkeys@expandafter}
+% \begin{macrocode}
+\def\kvsetkeys@expandafter#1#2{%
+ \expandafter\kv@parse\expandafter{#2}{%
+ \kv@processor@default{#1}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KVS@cmd}
+% \begin{macrocode}
+\def\KVS@cmd{0}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\KVS@cmd@inc}
+% \begin{macrocode}
+\def\KVS@cmd@inc{%
+& \edef\KVS@cmd{\the\numexpr\KVS@cmd+1}%
+$ \begingroup
+$ \count255=\KVS@cmd\relax
+$ \advance\count255 by 1\relax
+$ \edef\x{\endgroup
+$ \noexpand\def\noexpand\KVS@cmd{\number\count255}%
+$ }%
+$ \x
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\KVS@cmd@dec}
+% \begin{macrocode}
+\def\KVS@cmd@dec{%
+& \edef\KVS@cmd{\the\numexpr\KVS@cmd-1}%
+$ \begingroup
+$ \count255=\KVS@cmd\relax
+$ \advance\count255 by -1\relax
+$ \edef\x{\endgroup
+$ \noexpand\def\noexpand\KVS@cmd{\number\count255}%
+$ }%
+$ \x
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\KVS@empty}
+% \begin{macrocode}
+\def\KVS@empty{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\kvsetknownkeys}
+% \begin{macrocode}
+\def\kvsetknownkeys{%
+ \expandafter
+ \KVS@setknownkeys\csname KVS@cmd\KVS@cmd\endcsname{}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\KVS@setknownkeys}
+% \begin{macrocode}
+\long\def\KVS@setknownkeys#1#2#3#4#5{%
+ \let#1\KVS@empty
+ \KVS@cmd@inc
+ #2\kv@parse#2{#5}{\kv@processor@known{#3}#1}%
+ \KVS@cmd@dec
+ \let#4=#1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\kvsetknownkeys@expandafter}
+% \begin{macrocode}
+\def\kvsetknownkeys@expandafter{%
+ \expandafter
+ \KVS@setknownkeys
+ \csname KVS@cmd\KVS@cmd\endcsname\expandafter
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
\KVS@AtEnd%
%</package>
@@ -1261,7 +1543,7 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
\makeatletter
\chardef\KVS@TestMode=1 %
\makeatother
-\usepackage{kvsetkeys}[2011/04/07]
+\usepackage{kvsetkeys}[2012/04/25]
%<noetex>\let\unexpanded\SavedUnexpanded
\usepackage{qstest}
\IncludeTests{*}
@@ -1507,6 +1789,68 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
%</test2>
% \end{macrocode}
%
+% \subsection{Tests for key value processing handler}
+%
+% \begin{macrocode}
+%<*test4>
+\catcode`\{=1
+\catcode`\}=2
+\catcode`\#=6
+\catcode`\@=11
+\input kvdefinekeys.sty\relax
+\input kvsetkeys.sty\relax
+\input infwarerr.sty\relax
+\def\Error#1{%
+ \@PackageError{test}{#1}\@ehc
+}
+% \end{macrocode}
+% \begin{macrocode}
+\def\temp#1#2{%
+ \kv@define@key{#1}{#2}{%
+ \edef\result{%
+ \result
+ [#1:#2=##1]% hash-ok
+ }%
+ }%
+}
+\temp{FA}{key1}
+\temp{FA}{key2}
+\temp{FB}{key3}
+\temp{FB}{key3}
+% \end{macrocode}
+% \begin{macrocode}
+\setbox0=\hbox{%
+ \def\result{}%
+ \kvsetknownkeys{FA}\cmd{key1=234,key3=456}%
+ \def\expected{[FA:key1=234]}%
+ \ifx\expected\result
+ \else
+ \Error{%
+ \string\kvsetknownkeys/\string\result\MessageBreak
+ Expected: \expected\MessageBreak
+ Result: \space\result
+ }%
+ \fi
+ \def\expected{{key3}={456}}%
+ \ifx\cmd\expected
+ \else
+ \Error{%
+ \string\kvsetknownkeys/\string\cmd\MessageBreak
+ Expected: \expected\MessageBreak
+ Result: \space\cmd
+ }%
+ \fi
+}
+\ifdim\wd0=0pt %
+\else
+ \Error{Spurious spaces?}%
+\fi
+% \end{macrocode}
+% \begin{macrocode}
+\csname @@end\endcsname\end
+%</test4>
+% \end{macrocode}
+%
% \section{Installation}
%
% \subsection{Download}
@@ -1572,6 +1916,7 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
% test/kvsetkeys-test1.tex & doc/latex/oberdiek/test/kvsetkeys-test1.tex\\
% test/kvsetkeys-test2.tex & doc/latex/oberdiek/test/kvsetkeys-test2.tex\\
% test/kvsetkeys-test3.tex & doc/latex/oberdiek/test/kvsetkeys-test3.tex\\
+% test/kvsetkeys-test4.tex & doc/latex/oberdiek/test/kvsetkeys-test4.tex\\
% kvsetkeys.dtx & source/latex/oberdiek/kvsetkeys.dtx\\
% \end{tabular}^^A
% }^^A
@@ -1692,18 +2037,56 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
%\end{verbatim}
% \end{quote}
%
+% \section{Catalogue}
+%
+% The following XML file can be used as source for the
+% \href{http://mirror.ctan.org/help/Catalogue/catalogue.html}{\TeX\ Catalogue}.
+% The elements \texttt{caption} and \texttt{description} are imported
+% from the original XML file from the Catalogue.
+% The name of the XML file in the Catalogue is \xfile{kvsetkeys.xml}.
+% \begin{macrocode}
+%<*catalogue>
+<?xml version='1.0' encoding='us-ascii'?>
+<!DOCTYPE entry SYSTEM 'catalogue.dtd'>
+<entry datestamp='$Date$' modifier='$Author$' id='kvsetkeys'>
+ <name>kvsetkeys</name>
+ <caption>Key value parser with default handler support.</caption>
+ <authorref id='auth:oberdiek'/>
+ <copyright owner='Heiko Oberdiek' year='2006,2007,2009-2012'/>
+ <license type='lppl1.3'/>
+ <version number='1.16'/>
+ <description>
+ This package provides \kvsetkeys, a variant of package
+ <xref refid='keyval'>keyval</xref>'s <tt>\setkeys</tt>. It allows
+ the user to specify a handler that deals with unknown options.
+ Active commas and equal signs may be used (e.g. see
+ <xref refid='babel'>babel</xref>'s shorthands) and only one level
+ of curly braces are removed from the values.
+ <p/>
+ The package is part of the <xref refid='oberdiek'>oberdiek</xref> bundle.
+ </description>
+ <documentation details='Package documentation'
+ href='ctan:/macros/latex/contrib/oberdiek/kvsetkeys.pdf'/>
+ <ctan file='true' path='/macros/latex/contrib/oberdiek/kvsetkeys.dtx'/>
+ <miktex location='oberdiek'/>
+ <texlive location='oberdiek'/>
+ <install path='/macros/latex/contrib/oberdiek/oberdiek.tds.zip'/>
+</entry>
+%</catalogue>
+% \end{macrocode}
+%
% \begin{thebibliography}{9}
% \bibitem{tb94wright}
% A guide to key-value methods, Joseph Wright, second draft for
% \href{http://www.tug.org/tugboat}{TUGBoat}, 2009-03-17.
% \url{http://www.texdev.net/wp-content/uploads/2009/03/keyval.pdf}
-%
+%
% \bibitem{keyval}
% David Carlisle:
% \textit{The \xpackage{keyval} package};
% 1999/03/16 v1.13;
% \CTAN{macros/latex/required/graphics/keyval.dtx}.
-%
+%
% \end{thebibliography}
%
% \begin{History}
@@ -1781,6 +2164,28 @@ $ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
% \item
% \cs{kv@set@family@handler} with shorthand support.
% \end{Version}
+% \begin{Version}{2011/06/15 v1.14}
+% \item
+% Some optimizations in token register uses (GL, HO).
+% \end{Version}
+% \begin{Version}{2011/10/18 v1.15}
+% \item
+% \cs{kv@processor@known} and \cs{kvsetknownkeys} added.
+% \item
+% \cs{kvsetkeys@expandafter} and \cs{kvsetknownkeys@expandafter} added.
+% \item
+% Family handler can report success or failure by \cs{kv@handled@true}
+% or \cs{kv@handled@false}.
+% \item
+% \cs{kv@unset@family@handler} added.
+% \end{Version}
+% \begin{Version}{2012/04/25 v1.16}
+% \item
+% \cs{kv@processor@default} and \cs{kv@processor@known} define
+% macro \cs{kv@fam} for convenience.
+% \item
+% Catcode section: Catcode setting for \texttt{+} added for \hologo{eTeX}.
+% \end{Version}
% \end{History}
%
% \PrintIndex