%%
%% This is file `xkeyval.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xkeyval.dtx  (with options: `tex')
%% 
%% ---------------------------------------
%% Copyright (C) 2004-2005 Hendri Adriaens
%% ---------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) 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 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% This Current Maintainer of this work is Hendri Adriaens.
%%
%% This work consists of the files xkeyval.dtx and pst-xkey.dtx and
%% the from xkeyval.dtx derived files keyval.tex, xkvtxhdr.tex,
%% xkeyval.sty, xkeyval.tex, xkvltxp.sty, xkveca.cls, xkvecb.cls,
%% xkvesa.sty, xkvesb.sty, xkvesc.sty, xkvex1.tex, xkvex2.tex,
%% xkvex3.tex and xkvex4.tex and the from pst-xkey.dtx derived
%% files pst-xkey.sty and pst-xkey.tex.
%%
%% The following files constitute the xkeyval bundle and must be
%% distributed as a whole: readme, pst-xkey.pdf, xkeyval.pdf, keyval.tex,
%% pst-xkey.sty, pst-xkey.tex, xkeyval.sty, xkeyval.tex, xkvltxp.sty,
%% xkvtxhdr.tex, pst-xkey.dtx and xkeyval.dtx.
%%
\csname XKeyValLoaded\endcsname
\let\XKeyValLoaded\endinput
\edef\XKVcatcodes{%
  \catcode`\noexpand\@\the\catcode`\@\relax
  \catcode`\noexpand\=\the\catcode`\=\relax
  \catcode`\noexpand\,\the\catcode`\,\relax
  \catcode`\noexpand\:\the\catcode`\:\relax
  \let\noexpand\XKVcatcodes\relax
}
\catcode`\@11\relax
\catcode`\=12\relax
\catcode`\,12\relax
\catcode`\:12\relax
\newtoks\XKV@toks
\newif\ifXKV@st
\newif\ifXKV@sg
\newif\ifXKV@pl
\newif\ifXKV@knf
\newif\ifXKV@rkv
\newif\ifXKV@inpox
\let\XKV@rm\@empty
\ifx\ProvidesFile\@undefined
  \message{2005/01/30 v2.0 key=value parser (HA)}
  \input xkvtxhdr.tex
\else
  \ProvidesFile{xkeyval.tex}[2005/01/30 v2.0 key=value parser (HA)]
  \@addtofilelist{xkeyval.tex}
\fi
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
\long\def\XKV@afterfi#1\fi{\fi#1}
\long\def\XKV@afterelsefi#1\else#2\fi{\fi#1}
\ifx\ifcsname\@undefined\XKV@afterelsefi
  \def\XKV@ifundefined#1{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\ifx\csname#1\endcsname\relax
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }
\else
  \def\XKV@ifundefined#1{%
    \ifcsname#1\endcsname
      \expandafter\@secondoftwo
    \else
      \expandafter\@firstoftwo
    \fi
  }
\fi
\XKV@ifundefined{ver@keyval.sty}{
  \input keyval.tex
  \expandafter\def\csname ver@keyval.sty\endcsname{1999/03/16}
}{}
\long\def\@ifnextcharacter#1#2#3{%
  \@ifnextchar\bgroup
  {\@ifnextchar{#1}{#2}{#3}}%
  {\@ifncharacter{#1}{#2}{#3}}%
}
\long\def\@ifncharacter#1#2#3#4{%
  \if\string#1\string#4%
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {#2}{#3}#4%
}
\long\def\XKV@whilist#1:=#2\do#3\fi#4{%
  #3\expandafter\XKV@wh@list#2,\@nil,\@nil\@@#1#3\fi{#4}\fi
}
\long\def\XKV@wh@list#1,#2\@@#3#4\fi#5{%
  \begingroup\def#3{#1}\expandafter\endgroup
  \ifx#3\@nnil
    \expandafter\XKV@wh@l@st
  \else
    #4%
      \def#3{#1}#5\expandafter\expandafter\expandafter\XKV@wh@list
    \else
      \expandafter\expandafter\expandafter\XKV@wh@l@st
    \fi
  \fi
  #2\@@#3#4\fi{#5}%
}
\long\def\XKV@wh@l@st#1\@@#2#3\fi#4{}
\long\def\XKV@for#1:=#2\do#3{\expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}}
\def\XKV@addtomacro@n#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\XKV@addtomacro@o#1#2{%
  \expandafter\expandafter\expandafter\def\expandafter\expandafter
    \expandafter#1\expandafter\expandafter\expandafter{\expandafter#1#2}%
}
\def\XKV@addtolist@n#1#2{%
  \ifx#1\@empty
    \XKV@addtomacro@n#1{#2}%
  \else
    \XKV@addtomacro@n#1{,#2}%
  \fi
}
\def\XKV@addtolist@o#1#2{%
  \ifx#1\@empty
    \XKV@addtomacro@o#1#2%
  \else
    \XKV@addtomacro@o#1{\expandafter,#2}%
  \fi
}
\def\XKV@addtolist@x#1#2{\edef#1{#1\ifx#1\@empty\else,\fi#2}}
\def\@selective@sanitize{\@testopt\@s@lective@sanitize\@M}
\def\@s@lective@sanitize[#1]#2#3{%
  \begingroup
    \count@#1\relax\advance\count@\@ne
    \XKV@toks\expandafter{#3}%
    \def#3{#2}\@onelevel@sanitize#3%
    \edef#3{{#3}{\the\XKV@toks}}%
    \expandafter\@s@l@ctive@sanitize\expandafter#3#3
  \expandafter\endgroup\expandafter\def\expandafter#3\expandafter{#3}%
}
\def\@s@l@ctive@sanitize#1#2#3{%
  \def\@i{\futurelet\@@tok\@ii}%
  \def\@ii{%
    \expandafter\@iii\meaning\@@tok\relax
    \ifx\@@tok\@s@l@ctive@sanitize
      \let\@@cmd\@gobble
    \else
      \ifx\@@tok\@sptoken
        \XKV@toks\expandafter{#1}\edef#1{\the\XKV@toks\space}%
        \def\@@cmd{\afterassignment\@i\let\@@tok= }%
      \else
        \let\@@cmd\@iv
      \fi
    \fi
    \@@cmd
  }%
  \def\@iii##1##2\relax{\if##1\@backslashchar\let\@@tok\relax\fi}%
  \def\@iv##1{%
    \toks@\expandafter{#1}\XKV@toks{##1}%
    \ifx\@@tok\bgroup
      \advance\count@\m@ne
      \ifnum\count@>\z@
        \begingroup
          \def#1{\expandafter\@s@l@ctive@sanitize
            \csname\string#1\endcsname{#2}}%
          \expandafter#1\expandafter{\the\XKV@toks}%
          \XKV@toks\expandafter\expandafter\expandafter
            {\csname\string#1\endcsname}%
          \edef#1{\noexpand\XKV@toks{\the\XKV@toks}}%
        \expandafter\endgroup#1%
      \fi
      \edef#1{\the\toks@{\the\XKV@toks}}%
      \advance\count@\@ne
      \let\@@cmd\@i
    \else
      \edef#1{\expandafter\string\the\XKV@toks}%
      \expandafter\in@\expandafter{#1}{#2}%
      \edef#1{\the\toks@\ifin@#1\else
              \ifx\@@tok\@sptoken\space\else\the\XKV@toks\fi\fi}%
      \edef\@@cmd{\noexpand\@i\ifx\@@tok\@sptoken\the\XKV@toks\fi}%
    \fi
    \@@cmd
  }%
  \let#1\@empty\@i#3\@s@l@ctive@sanitize
}
\def\XKV@checksanitizea#1#2{%
  \XKV@ch@cksanitize{#1}#2=%
  \ifin@\else\XKV@ch@cksanitize{#1}#2,\fi
  \ifin@\@selective@sanitize[0]{,=}#2\fi
}
\def\XKV@checksanitizeb#1#2{%
  \XKV@ch@cksanitize{#1}#2,%
  \ifin@\@selective@sanitize[0],#2\fi
}
\def\XKV@ch@cksanitize#1#2#3{%
  \def#2{#1}%
  \@onelevel@sanitize#2%
  \@expandtwoargs\in@#3{#2}%
  \ifin@
    \def#2##1#3##2\@nil{%
      \def#2{##2}%
      \ifx#2\@empty\else\in@false\fi
    }%
    #2#1#3\@nil
  \fi
  \def#2{#1}%
}
\def\XKV@merge#1#2#3{%
  \XKV@checksanitizea{#2}\XKV@tempa
  \@for\XKV@tempa:=\XKV@tempa\do{%
    \XKV@pltrue
    #3\XKV@tempa\XKV@tempb
    \let\XKV@tempc#1%
    \let#1\@empty
    \@for\XKV@tempc:=\XKV@tempc\do{%
      #3\XKV@tempc\XKV@tempd
      \ifx\XKV@tempb\XKV@tempd
        \XKV@plfalse
        \XKV@addtolist@o#1\XKV@tempa
      \else
        \XKV@addtolist@o#1\XKV@tempc
      \fi
    }%
    \ifXKV@pl\XKV@addtolist@o#1\XKV@tempa\fi
  }%
  \ifXKV@st\global\let#1#1\fi
}
\def\XKV@delete#1#2#3{%
  \XKV@checksanitizeb{#2}\XKV@tempa
  \let\XKV@tempb#1%
  \let#1\@empty
  \@for\XKV@tempb:=\XKV@tempb\do{%
    #3\XKV@tempb\XKV@tempc
    \@expandtwoargs\in@{,\XKV@tempc,}{,\XKV@tempa,}%
    \ifin@\else\XKV@addtolist@o#1\XKV@tempb\fi
  }%
  \ifXKV@st\global\let#1#1\fi
}
\def\XKV@warn#1{\message{xkeyval warning: #1}}
\def\XKV@err#1{\errmessage{xkeyval error: #1}}
\def\KV@errx{\XKV@err}
\let\KV@err\KV@errx
\def\XKV@ifstar#1{\@ifnextcharacter*{\@firstoftwo{#1}}}
\def\XKV@ifplus#1{\@ifnextcharacter+{\@firstoftwo{#1}}}
\def\XKV@sp@deflist#1#2{%
  \let#1\@empty
  \def\XKV@resa{#2}%
  \@for\XKV@resa:=\XKV@resa\do{%
    \expandafter\KV@@sp@def\expandafter\XKV@resa\expandafter{\XKV@resa}%
    \edef#1{#1,\XKV@resa}%
  }%
  \ifx#1\@empty\else
    \def\XKV@resa,##1\@nil{\def#1{##1}}%
    \expandafter\XKV@resa#1\@nil
  \fi
}
\def\XKV@makepf#1{%
  \KV@@sp@def\XKV@prefix{#1}%
  \def\XKV@resa{XKV}%
  \ifx\XKV@prefix\XKV@resa
    \XKV@err{`XKV' prefix is not allowed}%
    \let\XKV@prefix\@empty
  \else
    \ifx\XKV@prefix\@empty\else
      \edef\XKV@prefix{\XKV@prefix @}%
    \fi
  \fi
}
\def\XKV@makehd#1{%
  \expandafter\KV@@sp@def\expandafter\XKV@header\expandafter{#1}%
  \ifx\XKV@header\@empty
    \let\XKV@header\XKV@prefix
  \else
    \edef\XKV@header{\XKV@prefix\XKV@header @}%
  \fi
}
\def\XKV@testopta#1{%
  \XKV@ifstar{\XKV@sttrue\XKV@t@stopta#1}{\XKV@stfalse\XKV@t@stopta#1}%
}
\def\XKV@t@stopta#1{%
  \XKV@ifplus{\XKV@pltrue\XKV@t@st@pta#1}{\XKV@plfalse\XKV@t@st@pta#1}%
}
\def\XKV@t@st@pta#1{\@testopt{\XKV@@t@st@pta#1}{KV}}
\def\XKV@@t@st@pta#1[#2]#3{%
  \XKV@makepf{#2}%
  \XKV@checksanitizeb{#3}\XKV@fams
  \expandafter\XKV@sp@deflist\expandafter\XKV@fams\expandafter{\XKV@fams}%
  \@testopt#1{}%
}
\def\XKV@testoptb#1{\@testopt{\XKV@t@stoptb#1}{KV}}
\def\XKV@t@stoptb#1[#2]#3{%
  \XKV@makepf{#2}%
  \XKV@makehd{#3}%
  \KV@@sp@def\XKV@tfam{#3}%
  #1%
}
\def\XKV@ifcmd#1#2#3{%
  \def\XKV@@ifcmd##1#2##2##3\@nil##4{%
    \def##4{##2}\ifx##4\@nnil
      \def##4{##1}\expandafter\@secondoftwo
    \else
      \expandafter\@firstoftwo
    \fi
  }%
  \XKV@@ifcmd#1#2{\@nil}\@nil#3%
}
\def\XKV@getkeyname#1#2{\expandafter\XKV@g@tkeyname#1=\@nil#2}
\def\XKV@g@tkeyname#1=#2\@nil#3{%
  \XKV@ifcmd{#1}\savevalue#3{\XKV@rkvtrue\XKV@sgfalse}{%
    \XKV@ifcmd{#1}\gsavevalue#3%
      {\XKV@rkvtrue\XKV@sgtrue}{\XKV@rkvfalse\XKV@sgfalse}%
  }%
}
\def\XKV@getsg#1#2{%
  \expandafter\XKV@ifcmd\expandafter{#1}\global#2\XKV@sgtrue\XKV@sgfalse
}
\def\define@key{\XKV@testoptb\XKV@define@key}
\def\XKV@define@key#1{%
  \@ifnextchar[{\XKV@d@fine@k@y{#1}}{%
    \expandafter\def\csname\XKV@header#1\endcsname####1}%
}
\def\XKV@d@fine@k@y#1[#2]{%
  \expandafter\def\csname\XKV@header#1@default\expandafter\endcsname
    \expandafter{\csname\XKV@header#1\endcsname{#2}}%
  \expandafter\def\csname\XKV@header#1\endcsname##1%
}
\def\define@boolkey{\XKV@testoptb\XKV@define@boolkey}
\def\XKV@define@boolkey#1{%
  \expandafter\newif\csname if\XKV@header#1\endcsname
  \expandafter\edef\csname\XKV@header#1\endcsname##1%
    {\noexpand\XKV@setbool{\XKV@header#1}{##1}}%
  \@ifnextchar[{\XKV@d@fine@boolkey{#1}}{}%
}
\def\XKV@d@fine@boolkey#1[#2]{%
  \expandafter\def\csname\XKV@header#1@default\expandafter\endcsname
    \expandafter{\csname\XKV@header#1\endcsname{#2}}%
}
\def\XKV@setbool#1#2{%
  \def\XKV@tempa{true}%
  \def\XKV@tempb{false}%
  \lowercase{\def\XKV@tempc{#2}}%
  \ifx\XKV@tempc\XKV@tempa\else
    \ifx\XKV@tempc\XKV@tempb\else
      \let\XKV@tempc\relax
    \fi
  \fi
  \ifx\XKV@tempc\relax
    \XKV@err{boolean can only be `true' or `false'}%
  \else
    \csname#1\XKV@tempc\endcsname
  \fi
}
\def\define@cmdkey{\XKV@testoptb\XKV@define@cmdkey}
\def\XKV@define@cmdkey#1{%
  \expandafter\edef\csname\XKV@header#1\endcsname##1{\noexpand\def
    \expandafter\noexpand\csname\XKV@header#1@cmd\endcsname{##1}}%
  \@ifnextchar[{\XKV@d@fine@cmdkey{#1}}{}%
}
\def\XKV@d@fine@cmdkey#1[#2]{%
  \expandafter\def\csname\XKV@header#1@default\expandafter\endcsname
    \expandafter{\csname\XKV@header#1\endcsname{#2}}%
}
\def\key@ifundefined{\@testopt\XKV@key@ifundefined{KV}}
\def\XKV@key@ifundefined[#1]#2{%
  \XKV@makepf{#1}%
  \XKV@sp@deflist\XKV@fams{#2}%
  \XKV@key@if@ndefined
}
\def\XKV@key@if@ndefined#1{%
  \XKV@knftrue
  \KV@@sp@def\XKV@tkey{#1}%
  \XKV@whilist\XKV@tfam:=\XKV@fams\do\ifXKV@knf\fi{%
    \XKV@makehd\XKV@tfam
    \XKV@ifundefined{\XKV@header\XKV@tkey}{}{\XKV@knffalse}%
  }%
  \ifXKV@knf
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\def\disable@keys{\XKV@testoptb\XKV@disable@keys}
\def\XKV@disable@keys#1{%
  \XKV@checksanitizeb{#1}\XKV@tempa
  \@for\XKV@tempa:=\XKV@tempa\do{%
    \XKV@ifundefined{\XKV@header\XKV@tempa}{%
      \XKV@err{key `\XKV@tempa' undefined}%
    }{%
      \edef\XKV@tempb{\noexpand\XKV@warn{key `\XKV@tempa' has been disabled}}%
      \XKV@ifundefined{\XKV@header\XKV@tempa @default}{%
        \edef\XKV@tempc{\noexpand\XKV@define@key{\XKV@tempa}}%
      }{%
        \edef\XKV@tempc{\noexpand\XKV@define@key{\XKV@tempa}[]}%
      }%
      \expandafter\XKV@tempc\expandafter{\XKV@tempb}%
    }%
  }%
}
\def\presetkeys{\XKV@stfalse\XKV@testoptb\XKV@presetkeys}
\def\gpresetkeys{\XKV@sttrue\XKV@testoptb\XKV@presetkeys}
\def\XKV@presetkeys#1#2{%
  \XKV@pr@setkeys{#1}{preseth}%
  \XKV@pr@setkeys{#2}{presett}%
}
\def\XKV@pr@setkeys#1#2{%
  \XKV@ifundefined{XKV@\XKV@header#2}{%
    \XKV@checksanitizea{#1}\XKV@tempa
    \ifXKV@st\expandafter\global\fi\expandafter\def
      \csname XKV@\XKV@header#2\expandafter\endcsname\expandafter{\XKV@tempa}%
  }{%
    \expandafter\XKV@merge\csname XKV@\XKV@header#2\endcsname{#1}\XKV@getkeyname
  }%
}
\def\delpresetkeys{\XKV@stfalse\XKV@testoptb\XKV@delpresetkeys}
\def\gdelpresetkeys{\XKV@sttrue\XKV@testoptb\XKV@delpresetkeys}
\def\XKV@delpresetkeys#1#2{%
  \XKV@d@lpresetkeys{#1}{preseth}%
  \XKV@d@lpresetkeys{#2}{presett}%
}
\def\XKV@d@lpresetkeys#1#2{%
  \XKV@ifundefined{XKV@\XKV@header#2}{%
    \XKV@err{no presets defined for `\XKV@header'}%
  }{%
    \expandafter\XKV@delete\csname XKV@\XKV@header#2\endcsname{#1}\XKV@getkeyname
  }%
}
\def\unpresetkeys{\XKV@stfalse\XKV@testoptb\XKV@unpresetkeys}
\def\gunpresetkeys{\XKV@sttrue\XKV@testoptb\XKV@unpresetkeys}
\def\XKV@unpresetkeys{%
  \XKV@ifundefined{XKV@\XKV@header preseth}{%
    \XKV@err{no presets defined for `\XKV@header'}%
  }{%
    \ifXKV@st\expandafter\global\fi\expandafter\let
      \csname XKV@\XKV@header preseth\endcsname\@undefined
    \ifXKV@st\expandafter\global\fi\expandafter\let
      \csname XKV@\XKV@header presett\endcsname\@undefined
  }%
}
\def\savekeys{\XKV@stfalse\XKV@testoptb\XKV@savekeys}
\def\gsavekeys{\XKV@sttrue\XKV@testoptb\XKV@savekeys}
\def\XKV@savekeys#1{%
  \XKV@ifundefined{XKV@\XKV@header save}{%
    \XKV@checksanitizeb{#1}\XKV@tempa
    \ifXKV@st\expandafter\global\fi\expandafter\def
      \csname XKV@\XKV@header save\expandafter\endcsname\expandafter{\XKV@tempa}%
  }{%
    \expandafter\XKV@merge\csname XKV@\XKV@header save\endcsname{#1}\XKV@getsg
  }%
}
\def\delsavekeys{\XKV@stfalse\XKV@testoptb\XKV@delsavekeys}
\def\gdelsavekeys{\XKV@sttrue\XKV@testoptb\XKV@delsavekeys}
\def\XKV@delsavekeys#1{%
  \XKV@ifundefined{XKV@\XKV@header save}{%
    \XKV@err{no save keys defined for `\XKV@header'}%
  }{%
    \expandafter\XKV@delete\csname XKV@\XKV@header save\endcsname{#1}\XKV@getsg
  }%
}
\def\unsavekeys{\XKV@stfalse\XKV@testoptb\XKV@unsavekeys}
\def\gunsavekeys{\XKV@sttrue\XKV@testoptb\XKV@unsavekeys}
\def\XKV@unsavekeys{%
  \XKV@ifundefined{XKV@\XKV@header save}{%
    \XKV@err{no save keys defined for `\XKV@header'}%
  }{%
    \ifXKV@st\expandafter\global\fi\expandafter\let
      \csname XKV@\XKV@header save\endcsname\@undefined
  }%
}
\def\setkeys{\XKV@testopta\XKV@setkeys}
\def\XKV@setkeys[#1]#2{%
  \def\XKV@tempa##1,{%
    \def\XKV@tempb{##1}%
    \ifx\XKV@tempb\@nnil\else
      \XKV@g@tkeyname##1=\@nil\XKV@tempb
      \XKV@addtolist@x\XKV@kna\XKV@tempb
      \expandafter\XKV@tempa
    \fi
  }%
  \XKV@checksanitizea{#2}\XKV@resb
  \let\XKV@kna\@empty
  \expandafter\XKV@tempa\XKV@resb,\@nil,%
  \let\XKV@rm\@empty
  \let\XKV@exec\@empty
  \XKV@usepresetkeys{#1}{preseth}%
  \expandafter\XKV@s@tkeys\expandafter{\XKV@resb}{#1}%
  \XKV@usepresetkeys{#1}{presett}%
  \XKV@exec
}
\def\XKV@usepresetkeys#1#2{%
  \XKV@for\XKV@tfam:=\XKV@fams\do{%
    \XKV@makehd\XKV@tfam
    \XKV@ifundefined{XKV@\XKV@header#2}{}{%
      \XKV@toks\expandafter\expandafter\expandafter
        {\csname XKV@\XKV@header#2\endcsname}%
      \@expandtwoargs\XKV@s@tkeys{\the\XKV@toks}%
        {\XKV@kna\ifx\XKV@kna\@empty\else,\fi#1}%
    }%
  }%
}
\def\XKV@s@tkeys#1#2{%
  \XKV@sp@deflist\XKV@kn{#2}%
  \XKV@s@tk@ys#1,\@nil,%
}
\def\XKV@s@tk@ys#1,{%
  \def\XKV@tempa{#1}%
  \ifx\XKV@tempa\@nnil\else
    \XKV@knftrue
    \XKV@split#1==\@nil
    \ifXKV@knf
      \ifXKV@inpox
        \ifx\XKV@doxs\relax
          \ifx\@currext\@clsextension\else
            \let\CurrentOption\XKV@tkey\@unknownoptionerror
          \fi
        \else
          \def\CurrentOption{#1}\XKV@doxs
        \fi
      \else
        \ifXKV@st
          \XKV@addtolist@n\XKV@rm{#1}%
        \else
          \XKV@err{`\XKV@tkey' undefined in families `\XKV@fams'}%
        \fi
      \fi
    \else
      \ifXKV@inpox\ifx\XKV@testclass\XKV@documentclass
        \XKV@useoption{#1}%
      \fi\fi
    \fi
    \expandafter\XKV@s@tk@ys
  \fi
}
\def\XKV@split#1=#2=#3\@nil{%
  \XKV@g@tkeyname#1=\@nil\XKV@tkey
  \expandafter\KV@@sp@def\expandafter\XKV@tkey\expandafter{\XKV@tkey}%
  \ifx\XKV@tkey\@empty
    \ifx\@empty#2\@empty\else
      \XKV@toks{#2}%
      \XKV@err{no key specified for value `\the\XKV@toks'}%
    \fi
    \XKV@knffalse
  \else
    \@expandtwoargs\in@{,\XKV@tkey,}{,\XKV@kn,}%
    \ifin@\XKV@knffalse\else
      \KV@@sp@def\XKV@tempa{#2}%
      \XKV@ifundefined{XKV@\XKV@header save}{}{%
        \expandafter\XKV@testsavekey\csname XKV@\XKV@header save\endcsname\XKV@tkey
      }%
      \ifXKV@rkv
        \ifXKV@sg\expandafter\global\fi\expandafter\let
          \csname XKV@\XKV@header\XKV@tkey @value\endcsname\XKV@tempa
      \fi
      \expandafter\XKV@replacepointers\expandafter{\XKV@tempa}%
      \ifXKV@pl
        \XKV@for\XKV@tfam:=\XKV@fams\do{%
          \XKV@makehd\XKV@tfam
          \expandafter\XKV@setkey@infam\expandafter{\XKV@tempa}{#3}%
        }%
      \else
        \XKV@whilist\XKV@tfam:=\XKV@fams\do\ifXKV@knf\fi{%
          \XKV@makehd\XKV@tfam
          \expandafter\XKV@setkey@infam\expandafter{\XKV@tempa}{#3}%
        }%
      \fi
    \fi
  \fi
}
\def\XKV@testsavekey#1#2{%
  \ifXKV@rkv\else
    \@for\XKV@resa:=#1\do{%
      \expandafter\XKV@ifcmd\expandafter{\XKV@resa}\global\XKV@resa{%
        \ifx#2\XKV@resa
          \XKV@rkvtrue\XKV@sgtrue
        \fi
      }{%
        \ifx#2\XKV@resa
          \XKV@rkvtrue\XKV@sgfalse
        \fi
      }%
    }%
  \fi
}
\def\XKV@replacepointers#1{%
  \let\XKV@tempa\@empty
  \let\XKV@resa\@empty
  \XKV@r@placepointers#1\usevalue\@nil
}
\def\XKV@r@placepointers#1\usevalue#2{%
  \XKV@addtomacro@n\XKV@tempa{#1}%
  \ifx\@nil#2\relax\else\XKV@afterfi
    \XKV@ifundefined{XKV@\XKV@header#2@value}{%
      \XKV@err{no value recorded for key `#2'; ignored}%
      \XKV@r@placepointers
    }{%
      \@expandtwoargs\in@{,#2,}{,\XKV@resa,}%
      \ifin@\XKV@afterelsefi
        \XKV@err{back linking pointers; pointer replacement canceled}%
      \else\XKV@afterfi
        \XKV@addtolist@x\XKV@resa{#2}%
        \expandafter\expandafter\expandafter\XKV@r@placepointers
          \csname XKV@\XKV@header#2@value\endcsname
      \fi
    }%
  \fi
}
\def\XKV@setkey@infam#1#2{%
  \XKV@ifundefined{\XKV@header\XKV@tkey}{}{%
    \XKV@knffalse
    \ifx\@empty#2\@empty
      \XKV@ifundefined{\XKV@header\XKV@tkey @default}{%
        \XKV@err{no value specified for key `\XKV@tkey'}%
      }{%
        \expandafter\expandafter\expandafter\XKV@default
          \csname\XKV@header\XKV@tkey @default\endcsname\@nil
      }%
    \else
      \XKV@addtomacro@o\XKV@exec{\csname\XKV@header\XKV@tkey\endcsname{#1}\relax}%
    \fi
  }%
}
\def\XKV@default#1#2\@nil{%
  \expandafter\edef\expandafter\XKV@tempa\expandafter{\expandafter\@gobble\string#1}%
  \edef\XKV@tempb{\XKV@header\XKV@tkey}%
  \@onelevel@sanitize\XKV@tempb
  \ifx\XKV@tempa\XKV@tempb
    \begingroup
      \expandafter\def\csname\XKV@header\XKV@tkey\endcsname##1{%
        \gdef\XKV@tempa{##1}%
      }%
      \csname\XKV@header\XKV@tkey @default\endcsname
    \endgroup
    \XKV@ifundefined{XKV@\XKV@header save}{}{%
      \expandafter\XKV@testsavekey\csname XKV@\XKV@header save\endcsname\XKV@tkey
    }%
    \ifXKV@rkv
      \ifXKV@sg\expandafter\global\fi\expandafter\let
        \csname XKV@\XKV@header\XKV@tkey @value\endcsname\XKV@tempa
    \fi
    \expandafter\XKV@replacepointers\expandafter{\XKV@tempa}%
    \XKV@addtomacro@o\XKV@exec{\expandafter#1\expandafter{\XKV@tempa}\relax}%
  \else
    \expandafter\XKV@addtomacro@o\expandafter\XKV@exec\expandafter
      {\csname\XKV@header\XKV@tkey @default\endcsname\relax}%
  \fi
}
\def\setrmkeys{\XKV@testopta\XKV@setrmkeys}
\def\XKV@setrmkeys[#1]{%
  \def\XKV@tempa{\XKV@setkeys[#1]}%
  \expandafter\XKV@tempa\expandafter{\XKV@rm}%
}
\XKVcatcodes
\endinput
%%
%% End of file `xkeyval.tex'.
