%%
%% This is file `xkvutils.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xkeyval.dtx  (with options: `xkvutils')
%% 
%% ---------------------------------------
%% Copyright (C) 2004-2014 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 file xkeyval.dtx and derived files
%% keyval.tex, xkvtxhdr.tex, xkeyval.sty, xkeyval.tex, xkvview.sty,
%% xkvltxp.sty, xkvutils.tex, pst-xkey.tex, pst-xkey.sty, xkveca.cls,
%% xkvecb.cls, xkvesa.sty, xkvesb.sty, xkvesc.sty, xkvex1.tex,
%% xkvex2.tex, xkvex3.tex and xkvex4.tex.
%%
%% The following files constitute the xkeyval bundle and must be
%% distributed as a whole: readme, xkeyval.pdf, keyval.tex,
%% pst-xkey.sty, pst-xkey.tex, xkeyval.sty, xkeyval.tex, xkvview.sty,
%% xkvltxp.sty, xkvtxhdr.tex, xkvutils.tex, pst-xkey.dtx and xkeyval.dtx.
%%
\csname XKeyValUtilsLoaded\endcsname
\let\XKeyValUtilsLoaded\endinput
\edef\XKeyValUtilsCatcodes{%
  \catcode`\noexpand\@\the\catcode`\@\relax
  \let\noexpand\XKeyValUtilsCatcodes\relax
}
\catcode`\@=11\relax
\newtoks\XKV@toks
\newtoks\XKV@tempa@toks
\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
  \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@for@n#1#2#3{%
  \XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}%
  \ifx#2\@empty
    \XKV@for@break
  \else
    \expandafter\XKV@f@r
  \fi
  #2{#3}#1,\@nil,%
}
\long\def\XKV@f@r#1#2#3,{%
  \XKV@tempa@toks{#3}\edef#1{\the\XKV@tempa@toks}%
  \ifx#1\@nnil
    \expandafter\@gobbletwo
  \else
    #2\expandafter\XKV@f@r
  \fi
  #1{#2}%
}
\long\def\XKV@for@break #1\@nil,{\fi}
\long\def\XKV@for@o#1{\expandafter\XKV@for@n\expandafter{#1}}
\long\def\XKV@for@en#1#2#3{\XKV@f@r#2{#3}#1,\@nil,}
\long\def\XKV@for@eo#1#2#3{%
  \def#2{\XKV@f@r#2{#3}}\expandafter#2#1,\@nil,%
}
\long\def\XKV@whilist#1#2#3\fi#4{%
  #3\expandafter\XKV@wh@list#1,\@nil,\@nil\@@#2#3\fi{#4}{}\fi
}
\long\def\XKV@wh@list#1,#2\@@#3#4\fi#5#6{%
  \def#3{#1}%
  \ifx#3\@nnil
    \def#3{#6}\expandafter\XKV@wh@l@st
  \else
    #4%
      #5\expandafter\expandafter\expandafter\XKV@wh@list
    \else
      \def#3{#6}\expandafter\expandafter\expandafter\XKV@wh@l@st
    \fi
  \fi
  #2\@@#3#4\fi{#5}{#1}%
}
\long\def\XKV@wh@l@st#1\@@#2#3\fi#4#5{}
\long\def\XKV@addtomacro@n#1#2{%
  \XKV@tempa@toks\expandafter{#1#2}%
  \edef#1{\the\XKV@tempa@toks}%
}
\def\XKV@addtomacro@o#1#2{%
  \expandafter\XKV@addtomacro@n\expandafter#1\expandafter{#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\XKV@tempa@toks\expandafter{#3}%
  \expandafter\endgroup\expandafter\toks@\expandafter{\the\XKV@tempa@toks}%
  \edef#3{\the\toks@}%
}
\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
}
\long\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
}
\long\def\XKV@ch@cksanitize#1#2#3{%
  \XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}%
  \@onelevel@sanitize#2%
  \@expandtwoargs\in@#3{#2}%
  \ifin@
    \long\def#2##1#3##2\@nil{%
      \XKV@tempa@toks{##2}\edef#2{\the\XKV@tempa@toks}%
      \ifx#2\@empty\else\in@false\fi
    }%
    #2#1#3\@nil
  \fi
  \XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}%
}
\def\XKV@sp@deflist#1#2{%
  \let#1\@empty
  \XKV@for@n{#2}\XKV@resa{%
    \expandafter\KV@@sp@def\expandafter\XKV@resa\expandafter{\XKV@resa}%
    \XKV@addtomacro@o#1{\expandafter,\XKV@resa}%
  }%
  \ifx#1\@empty\else
    \def\XKV@resa,##1\@nil{\def#1{##1}}%
    \expandafter\XKV@resa#1\@nil
  \fi
}
\def\XKV@merge#1#2#3{%
  \XKV@checksanitizea{#2}\XKV@tempa
  \XKV@for@o\XKV@tempa\XKV@tempa{%
    \XKV@pltrue
    #3\XKV@tempa\XKV@tempb
    \let\XKV@tempc#1%
    \let#1\@empty
    \XKV@for@o\XKV@tempc\XKV@tempc{%
      #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
  \XKV@for@o\XKV@tempb\XKV@tempb{%
    #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
}
\XKeyValUtilsCatcodes
\endinput
%%
%% End of file `xkvutils.tex'.
