%%
%% This is file `kvsetkeys.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% kvsetkeys.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: kvsetkeys
%% Version: 2012/04/25 v1.16
%% 
%% 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
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and 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.
%% 
%% 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-test4.tex.
%% 
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode35=6 % #
  \catcode39=12 % '
  \catcode44=12 % ,
  \catcode45=12 % -
  \catcode46=12 % .
  \catcode58=12 % :
  \catcode64=11 % @
  \catcode123=1 % {
  \catcode125=2 % }
  \expandafter\let\expandafter\x\csname ver@kvsetkeys.sty\endcsname
  \ifx\x\relax % plain-TeX, first loading
  \else
    \def\empty{}%
    \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
    \else
      \expandafter\ifx\csname PackageInfo\endcsname\relax
        \def\x#1#2{%
          \immediate\write-1{Package #1 Info: #2.}%
        }%
      \else
        \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
      \fi
      \x{kvsetkeys}{The package is already loaded}%
      \aftergroup\endinput
    \fi
  \fi
\endgroup%
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode35=6 % #
  \catcode39=12 % '
  \catcode40=12 % (
  \catcode41=12 % )
  \catcode44=12 % ,
  \catcode45=12 % -
  \catcode46=12 % .
  \catcode47=12 % /
  \catcode58=12 % :
  \catcode64=11 % @
  \catcode91=12 % [
  \catcode93=12 % ]
  \catcode123=1 % {
  \catcode125=2 % }
  \expandafter\ifx\csname ProvidesPackage\endcsname\relax
    \def\x#1#2#3[#4]{\endgroup
      \immediate\write-1{Package: #3 #4}%
      \xdef#1{#4}%
    }%
  \else
    \def\x#1#2[#3]{\endgroup
      #2[{#3}]%
      \ifx#1\@undefined
        \xdef#1{#3}%
      \fi
      \ifx#1\relax
        \xdef#1{#3}%
      \fi
    }%
  \fi
\expandafter\x\csname ver@kvsetkeys.sty\endcsname
\ProvidesPackage{kvsetkeys}%
  [2012/04/25 v1.16 Key value parser (HO)]%
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode123=1 % {
  \catcode125=2 % }
  \catcode64=11 % @
  \def\x{\endgroup
    \expandafter\edef\csname KVS@AtEnd\endcsname{%
      \endlinechar=\the\endlinechar\relax
      \catcode13=\the\catcode13\relax
      \catcode32=\the\catcode32\relax
      \catcode35=\the\catcode35\relax
      \catcode61=\the\catcode61\relax
      \catcode64=\the\catcode64\relax
      \catcode123=\the\catcode123\relax
      \catcode125=\the\catcode125\relax
    }%
  }%
\x\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode35=6 % #
\catcode64=11 % @
\catcode123=1 % {
\catcode125=2 % }
\def\TMP@EnsureCode#1#2{%
  \edef\KVS@AtEnd{%
    \KVS@AtEnd
    \catcode#1=\the\catcode#1\relax
  }%
  \catcode#1=#2\relax
}
\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}% [
\TMP@EnsureCode{93}{12}% ]
\TMP@EnsureCode{94}{7}% ^ (superscript)
\TMP@EnsureCode{96}{12}% `
\TMP@EnsureCode{126}{13}% ~ (active)
\edef\KVS@AtEnd{\KVS@AtEnd\noexpand\endinput}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \def\TMP@RequirePackage#1[#2]{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname ver@#1.sty\endcsname\relax
      \input #1.sty\relax
    \fi
  }%
  \TMP@RequirePackage{infwarerr}[2007/09/09]%
  \TMP@RequirePackage{etexcmds}[2010/01/28]%
\else
  \RequirePackage{infwarerr}[2007/09/09]%
  \RequirePackage{etexcmds}[2010/01/28]%
\fi
\expandafter\ifx\csname toks@\endcsname\relax
  \toksdef\toks@=0 %
\fi
\begingroup\expandafter\endgroup
\ifcase0\ifetex@unexpanded
          \expandafter\ifx\csname ifcsname\endcsname\relax
          \else
            \expandafter\ifx\csname unless\endcsname\relax
            \else
              1%
            \fi
          \fi
        \fi
  \catcode`\$=9 % ignore
  \catcode`\&=14 % comment
\else % e-TeX
  \catcode`\$=14 % comment
  \catcode`\&=9  % ignore
\fi
\def\KVS@Empty{}
\long\def\KVS@FirstOfTwo#1#2{#1}
\long\def\KVS@SecondOfTwo#1#2{#2}
\long\def\KVS@IfEmpty#1{%
& \edef\KVS@Temp{\etex@unexpanded{#1}}%
$ \begingroup
$   \toks@{#1}%
$   \edef\KVS@Temp{\the\toks@}%
$ \expandafter\endgroup
  \ifx\KVS@Temp\KVS@Empty
    \expandafter\KVS@FirstOfTwo
  \else
    \expandafter\KVS@SecondOfTwo
  \fi
}
\long\def\kv@normalize#1{%
  \begingroup
    \toks@{,#1,}%
    \KVS@Comma
    \KVS@SpaceComma
    \KVS@CommaSpace
    \KVS@CommaComma
    \KVS@Equals
    \KVS@SpaceEquals
    \KVS@EqualsSpace
    \xdef\KVS@Global{\the\toks@}%
  \endgroup
  \let\kv@list\KVS@Global
}
\def\comma@normalize#1{%
  \begingroup
    \toks@{,#1,}%
    \KVS@Comma
    \KVS@SpaceComma
    \KVS@CommaSpace
    \KVS@CommaComma
    \xdef\KVS@Global{\the\toks@}%
  \endgroup
  \let\comma@list\KVS@Global
}
\begingroup
  \lccode`\,=`\,%
  \lccode`\~=`\,%
\lowercase{\endgroup
  \def\KVS@Comma{%
    \toks@\expandafter{\expandafter}\expandafter
    \KVS@@Comma\the\toks@~\KVS@Nil
  }%
  \long\def\KVS@@Comma#1~#2\KVS@Nil{%
    \toks@\expandafter{\the\toks@#1}%
    \KVS@IfEmpty{#2}{%
    }{%
      \KVS@@Comma,#2\KVS@Nil
    }%
  }%
}
\def\KVS@SpaceComma#1{%
  \def\KVS@SpaceComma{%
    \expandafter\KVS@@SpaceComma\the\toks@#1,\KVS@Nil
  }%
}
\KVS@SpaceComma{ }
\long\def\KVS@@SpaceComma#1 ,#2\KVS@Nil{%
  \KVS@IfEmpty{#2}{%
    \toks@{#1}%
  }{%
    \KVS@@SpaceComma#1,#2\KVS@Nil
  }%
}
\def\KVS@CommaSpace{%
  \expandafter\KVS@@CommaSpace\the\toks@, \KVS@Nil
}
\long\def\KVS@@CommaSpace#1, #2\KVS@Nil{%
  \KVS@IfEmpty{#2}{%
    \toks@{#1}%
  }{%
    \KVS@@CommaSpace#1,#2\KVS@Nil
  }%
}
\def\KVS@CommaComma{%
  \expandafter\KVS@@CommaComma\the\toks@,\KVS@Nil
}
\long\def\KVS@@CommaComma#1,,#2\KVS@Nil{%
  \KVS@IfEmpty{#2}{%
    \toks@{#1,}% (!)
  }{%
    \KVS@@CommaComma#1,#2\KVS@Nil
  }%
}
\begingroup
  \lccode`\==`\=%
  \lccode`\~=`\=%
\lowercase{\endgroup
  \def\KVS@Equals{%
    \toks@\expandafter{\expandafter}\expandafter
    \KVS@@Equals\the\toks@~\KVS@Nil
  }%
  \long\def\KVS@@Equals#1~#2\KVS@Nil{%
    \edef\KVS@Temp{\the\toks@}%
    \ifx\KVS@Temp\KVS@Empty
      \expandafter\KVS@FirstOfTwo
    \else
      \expandafter\KVS@SecondOfTwo
    \fi
    {%
      \toks@{#1}%
    }{%
      \toks@\expandafter{\the\toks@=#1}%
    }%
    \KVS@IfEmpty{#2}{%
    }{%
      \KVS@@Equals#2\KVS@Nil
    }%
  }%
}
\def\KVS@SpaceEquals#1{%
  \def\KVS@SpaceEquals{%
    \expandafter\KVS@@SpaceEquals\the\toks@#1=\KVS@Nil
  }%
}
\KVS@SpaceEquals{ }
\long\def\KVS@@SpaceEquals#1 =#2\KVS@Nil{%
  \KVS@IfEmpty{#2}{%
    \toks@{#1}%
  }{%
    \KVS@@SpaceEquals#1=#2\KVS@Nil
  }%
}
\def\KVS@EqualsSpace{%
  \expandafter\KVS@@EqualsSpace\the\toks@= \KVS@Nil
}
\long\def\KVS@@EqualsSpace#1= #2\KVS@Nil{%
  \KVS@IfEmpty{#2}{%
    \toks@{#1}%
  }{%
    \KVS@@EqualsSpace#1=#2\KVS@Nil
  }%
}
\long\def\kv@parse#1{%
  \kv@normalize{#1}%
  \expandafter\kv@parse@normalized\expandafter{\kv@list}%
}
\long\def\kv@parse@normalized#1#2{%
  \KVS@Parse#1,\KVS@Nil{#2}%
}
\long\def\KVS@Parse#1,#2\KVS@Nil#3{%
  \KVS@IfEmpty{#1}{%
  }{%
    \KVS@Process#1=\KVS@Nil{#3}%
  }%
  \KVS@MaybeBreak
  \KVS@IfEmpty{#2}{%
  }{%
    \KVS@Parse#2\KVS@Nil{#3}%
  }%
}
\long\def\KVS@Process#1=#2\KVS@Nil#3{%
  \let\KVS@MaybeBreak\relax
  \def\kv@key{#1}%
  \KVS@IfEmpty{#2}{%
    \let\kv@value\relax
    #3{#1}{}%
  }{%
    \KVS@@Process{#1}#2\KVS@Nil{#3}%
  }%
}
\long\def\KVS@@Process#1#2=\KVS@Nil#3{%
& \edef\kv@value{\etex@unexpanded{#2}}%
$ \begingroup
$   \toks@{#2}%
$   \xdef\KVS@Global{\the\toks@}%
$ \endgroup
$ \let\kv@value\KVS@Global
  #3{#1}{#2}%
}
\let\KVS@MaybeBreak\relax
\def\KVS@break#1#2#3#4{%
  \let\KVS@MaybeBreak\relax
}
\def\kv@break{%
  \let\KVS@MaybeBreak\KVS@break
}
\def\comma@parse#1{%
  \comma@normalize{#1}%
  \expandafter\comma@parse@normalized\expandafter{\comma@list}%
}
\def\comma@parse@normalized#1#2{%
  \KVS@CommaParse#1,\KVS@Nil{#2}%
}
\def\KVS@CommaParse#1,#2\KVS@Nil#3{%
  \KVS@IfEmpty{#1}{%
  }{%
    \def\comma@entry{#1}%
    #3{#1}%
  }%
  \KVS@MaybeBreak
  \KVS@IfEmpty{#2}{%
  }{%
    \KVS@CommaParse#2\KVS@Nil{#3}%
  }%
}
\def\comma@break{%
  \let\KVS@MaybeBreak\KVS@break
}
\def\kv@handled@false{%
  \let\ifkv@handled@\iffalse
}
\def\kv@handled@true{%
  \let\ifkv@handled@\iftrue
}
\kv@handled@true
\def\kv@processor@default#1#2{%
  \begingroup
    \csname @safe@activestrue\endcsname
    \let\ifincsname\iftrue
    \edef\KVS@temp{\endgroup
      \noexpand\KVS@ProcessorDefault{#1}{#2}%
    }%
  \KVS@temp
}
\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
&   \unless\ifcsname KVS@#1@handler\endcsname
$   \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
&     \unless\ifcsname KV@#1@#2@default\endcsname
$     \begingroup\expandafter\expandafter\expandafter\endgroup
$     \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax
        \kv@error@novalue{#1}{#2}%
      \else
        \csname KV@#1@#2@default\endcsname
        \relax
      \fi
    \else
      \csname KV@#1@#2\endcsname{#3}%
    \fi
  \fi
}
\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
}
\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
}
\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
}
\long\def\kv@set@family@handler#1#2{%
  \begingroup
    \csname @safe@activestrue\endcsname
    \let\ifincsname\iftrue
  \expandafter\endgroup
  \expandafter\def\csname KVS@#1@handler\endcsname##1##2{#2}%
}
\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
}
\def\kv@error@novalue{%
  \kv@error@generic{No value specified for}%
}
\def\kv@error@unknownkey{%
  \kv@error@generic{Undefined}%
}
\def\kv@error@generic#1#2#3{%
  \@PackageError{kvsetkeys}{%
    #1 key `#3'%
  }{%
    The keyval family of the key `#3' is `#2'.\MessageBreak
    The setting of the key is ignored because of the error.\MessageBreak
    \MessageBreak
    \@ehc
  }%
}
\long\def\kvsetkeys#1#2{%
  \kv@parse{#2}{\kv@processor@default{#1}}%
}
\def\kvsetkeys@expandafter#1#2{%
  \expandafter\kv@parse\expandafter{#2}{%
    \kv@processor@default{#1}%
  }%
}
\def\KVS@cmd{0}%
\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
}
\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
}
\def\KVS@empty{}
\def\kvsetknownkeys{%
  \expandafter
  \KVS@setknownkeys\csname KVS@cmd\KVS@cmd\endcsname{}%
}
\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%
}
\def\kvsetknownkeys@expandafter{%
  \expandafter
  \KVS@setknownkeys
      \csname KVS@cmd\KVS@cmd\endcsname\expandafter
}
\KVS@AtEnd%
\endinput
%%
%% End of file `kvsetkeys.sty'.
