%%
%% This is file `kvoptions-patch.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% kvoptions.dtx  (with options: `patch')
%% 
%% This is a generated file.
%% 
%% Project: kvoptions
%% Version: 2016/05/16 v3.12
%% 
%% Copyright (C) 2004, 2006, 2007, 2009-2011 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.
%% 
%% This work consists of the main source file kvoptions.dtx
%% and the derived files
%%    kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv,
%%    kvoptions-patch.sty, example-mycolorsetup.sty,
%%    kvoptions-test1.tex, kvoptions-test2.tex,
%%    kvoptions-test3.tex, kvoptions-test4.tex,
%%    kvoptions-test4.sty.
%% 
%% No we don't need the option 'color'.
%% With color support option 'emphcolor' will dynamically
%% change the color of \emph statements.
\def\KVO@IfDefThen#1#2{%
  \ifx#1\ltx@undefined
  \else
    \ifx#1\relax
    \else
      #2%
    \fi
  \fi
}%
\def\KVO@GetClassOptionsList{%
  \let\KVO@classoptionslist\@classoptionslist
  \KVO@IfDefThen\@classoptionslist{%
    \KVO@IfDefThen\XKV@documentclass{%
      \ifx\XKV@documentclass\ltx@empty
      \else
        \KVO@IfDefThen\XKV@classoptionslist{%
          \ifx\XKV@classoptionslist\ltx@empty
          \else
            \let\KVO@classoptionslist\XKV@classoptionslist
          \fi
        }%
      \fi
    }%
  }%
}%
\NeedsTeXFormat{LaTeX2e}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode123=1 % {
  \catcode125=2 % }
  \catcode64=11 % @
  \def\x{\endgroup
    \expandafter\edef\csname KVO@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\KVO@AtEnd{%
    \KVO@AtEnd
    \catcode#1=\the\catcode#1\relax
  }%
  \catcode#1=#2\relax
}
\TMP@EnsureCode{39}{12}% '
\TMP@EnsureCode{40}{12}% (
\TMP@EnsureCode{41}{12}% )
\TMP@EnsureCode{43}{12}% +
\TMP@EnsureCode{44}{12}% ,
\TMP@EnsureCode{45}{12}% -
\TMP@EnsureCode{46}{12}% .
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{58}{12}% :
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{91}{12}% [
\TMP@EnsureCode{93}{12}% ]
\TMP@EnsureCode{96}{12}% `
\TMP@EnsureCode{124}{12}% |
\edef\KVO@AtEnd{\KVO@AtEnd\noexpand\endinput}
\ProvidesPackage{kvoptions-patch}%
  [2016/05/16 v3.12 LaTeX patch for keyval options (HO)]%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname eTeXversion\endcsname\relax
  \PackageWarningNoLine{kvoptions-patch}{%
    Package loading is aborted, because e-TeX is missing%
  }%
  \expandafter\KVO@AtEnd
\fi%
\RequirePackage{etexcmds}[2007/09/09]
\ifetex@unexpanded
\else
  \PackageError{kvoptions-patch}{%
    Could not find eTeX's \string\unexpanded.\MessageBreak
    Try adding \string\RequirePackage\string{etexcmds\string} %
    before \string\documentclass%
  }\@ehd
  \expandafter\KVO@AtEnd
\fi%
\@ifpackageloaded{xkvltxp}{%
  \PackageWarningNoLine{kvoptions}{%
    Option `patch' cannot be used together with\MessageBreak
    package `xkvltxp' that is already loaded.\MessageBreak
    Therefore package loading is aborted%
  }%
  \KVO@AtEnd
}{}%
\def\@if@ptions#1#2#3{%
  \begingroup
    \KVO@normalize\KVO@temp{#3}%
    \edef\x{\endgroup
      \noexpand\@if@pti@ns{%
        \detokenize\expandafter\expandafter\expandafter{%
          \csname opt@#2.#1\endcsname
        }%
      }{%
        \detokenize\expandafter{\KVO@temp}%
      }%
    }%
  \x
}
\def\@pass@ptions#1#2#3{%
  \KVO@normalize\KVO@temp{#2}%
  \@ifundefined{opt@#3.#1}{%
    \expandafter\gdef\csname opt@#3.#1%
          \expandafter\endcsname\expandafter{%
      \KVO@temp
    }%
  }{%
    \expandafter\gdef\csname opt@#3.#1%
          \expandafter\expandafter\expandafter\endcsname
          \expandafter\expandafter\expandafter{%
      \csname opt@#3.#1\expandafter\endcsname\expandafter,\KVO@temp
    }%
  }%
}
\def\ProcessOptions{%
  \let\ds@\@empty
  \@ifundefined{opt@\@currname.\@currext}{%
    \let\@curroptions\@empty
  }{%
    \expandafter\expandafter\expandafter\def
    \expandafter\expandafter\expandafter\@curroptions
    \expandafter\expandafter\expandafter{%
      \csname opt@\@currname.\@currext\endcsname
    }%
  }%
  \@ifstar\KVO@xprocess@ptions\KVO@process@ptions
}
\def\KVO@process@ptions{%
  \@for\CurrentOption:=\@declaredoptions\do{%
    \ifx\CurrentOption\@empty
    \else
      \begingroup
        \ifx\@currext\@clsextension
          \toks@{}%
        \else
          \KVO@GetClassOptionsList
          \toks@\expandafter{\KVO@classoptionslist,}%
        \fi
        \toks\tw@\expandafter{\@curroptions}%
        \edef\x{\endgroup
          \noexpand\in@{,\CurrentOption,}{,\the\toks@\the\toks\tw@,}%
        }%
      \x
      \ifin@
        \KVO@use@ption
        \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
      \fi
    \fi
  }%
  \KVO@process@pti@ns
}
\def\KVO@xprocess@ptions{%
  \ifx\@currext\@clsextension
  \else
    \KVO@GetClassOptionsList
    \@for\CurrentOption:=\KVO@classoptionslist\do{%
      \ifx\CurrentOption\@empty
      \else
        \KVO@in@\CurrentOption\@declaredoptions
        \ifin@
          \KVO@use@ption
          \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
        \fi
      \fi
    }%
  \fi
  \KVO@process@pti@ns
}
\def\KVO@in@#1#2{%
  \in@false
  \begingroup
    \@for\x:=#2\do{%
      \ifx\x#1\relax
        \in@true
      \fi
    }%
    \edef\x{\endgroup
      \ifin@
        \noexpand\in@true
      \fi
    }%
  \x
}
\def\KVO@process@pti@ns{%
  \@for\CurrentOption:=\@curroptions\do{%
    \@ifundefined{ds@\KVO@SanitizedCurrentOption}{%
      \KVO@use@ption
      \default@ds
    }%
    \KVO@use@ption
  }%
  \@for\CurrentOption:=\@declaredoptions\do{%
    \expandafter\let\csname ds@\CurrentOption\endcsname\relax
  }%
  \let\CurrentOption\@empty
  \let\@fileswith@pti@ns\@@fileswith@pti@ns
  \AtEndOfPackage{\let\@unprocessedoptions\relax}%
}
\def\KVO@use@ption{%
  \begingroup
    \edef\x{\endgroup
      \noexpand\@removeelement{%
        \detokenize\expandafter{\CurrentOption}%
      }{%
        \detokenize\expandafter{\@unusedoptionlist}%
      }%
    }%
  \x\@unusedoptionlist
  \csname ds@\KVO@SanitizedCurrentOption\endcsname
}
\def\OptionNotUsed{%
  \ifx\@currext\@clsextension
    \xdef\@unusedoptionlist{%
      \ifx\@unusedoptionlist\@empty
      \else
        \detokenize\expandafter{\@unusedoptionlist,}%
      \fi
      \detokenize\expandafter{\CurrentOption}%
    }%
  \fi
}
\def\CurrentOption@SaveLevel{0}
\def\ExecuteOptions{%
  \expandafter\KVO@ExecuteOptions
      \csname CurrentOption@\CurrentOption@SaveLevel\endcsname
}
\def\KVO@ExecuteOptions#1#2{%
  \let#1\CurrentOption
  \edef\CurrentOption@SaveLevel{%
    \the\numexpr\CurrentOption@SaveLevel+1%
  }%
  \@for\CurrentOption:=#2\do{%
    \csname ds@\CurrentOption\endcsname
  }%
  \edef\CurrentOption@SaveLevel{%
    \the\numexpr\CurrentOption@SaveLevel-1%
  }%
  \let\CurrentOption#1%
}
\def\KVO@fileswith@pti@ns#1[#2]#3[#4]{%
  \ifx#1\@clsextension
    \ifx\@classoptionslist\relax
      \KVO@normalize\KVO@temp{#2}%
      \expandafter\gdef\expandafter\@classoptionslist\expandafter{%
        \KVO@temp
      }%
      \def\reserved@a{%
        \KVO@onefilewithoptions{#3}[{#2}][{#4}]#1%
        \@documentclasshook
      }%
    \else
      \def\reserved@a{%
        \KVO@onefilewithoptions{#3}[{#2}][{#4}]#1%
      }%
    \fi
  \else
    \begingroup
      \let\KVO@temp\relax
      \let\KVO@onefilewithoptions\relax
      \let\@pkgextension\relax
      \def\reserved@b##1,{%
        \ifx\@nil##1\relax
        \else
          \ifx\relax##1\relax
          \else
            \KVO@onefilewithoptions{##1}[{\KVO@temp}][{#4}]%
            \@pkgextension
          \fi
          \expandafter\reserved@b
        \fi
      }%
      \edef\reserved@a{\zap@space#3 \@empty}%
      \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nil,}%
      \toks@{#2}%
      \def\KVO@temp{\the\toks@}%
    \edef\reserved@a{\endgroup \reserved@a}%
  \fi
  \reserved@a
}
\def\KVO@onefilewithoptions#1[#2][#3]#4{%
  \@pushfilename
  \xdef\@currname{#1}%
  \global\let\@currext#4%
  \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty
  \let\CurrentOption\@empty
  \@reset@ptions
  \makeatletter
  \def\reserved@a{%
    \@ifl@aded\@currext{#1}{%
      \@if@ptions\@currext{#1}{#2}{%
      }{%
        \begingroup
          \@ifundefined{opt@#1.\@currext}{%
            \def\x{}%
          }{%
            \edef\x{%
              \expandafter\expandafter\expandafter\strip@prefix
              \expandafter\meaning\csname opt@#1.\@currext\endcsname
            }%
          }%
          \def\y{#2}%
          \edef\y{\expandafter\strip@prefix\meaning\y}%
          \@latex@error{Option clash for \@cls@pkg\space #1}{%
            The package #1 has already been loaded %
            with options:\MessageBreak
            \space\space[\x]\MessageBreak
            There has now been an attempt to load it %
             with options\MessageBreak
            \space\space[\y]\MessageBreak
            Adding the global options:\MessageBreak
            \space\space
                 \x,\y\MessageBreak
            to your \noexpand\documentclass declaration may fix this.%
            \MessageBreak
            Try typing \space <return> \space to proceed.%
          }%
        \endgroup
      }%
    }{%
      \@pass@ptions\@currext{#2}{#1}%
      \global\expandafter
      \let\csname ver@\@currname.\@currext\endcsname\@empty
      \InputIfFileExists
        {\@currname.\@currext}%
        {}%
        {\@missingfileerror\@currname\@currext}%
      \let\@unprocessedoptions\@@unprocessedoptions
      \csname\@currname.\@currext-h@@k\endcsname
      \expandafter\let\csname\@currname.\@currext-h@@k\endcsname
              \@undefined
      \@unprocessedoptions
    }%
    \@ifl@ter\@currext{#1}{#3}{%
    }{%
      \@latex@warning@no@line{%
        You have requested,\on@line, %
        version\MessageBreak
          #3' of \@cls@pkg\space #1,\MessageBreak
        but only version\MessageBreak
         `\csname ver@#1.\@currext\endcsname'\MessageBreak
        is available%
      }%
    }%
    \ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi
    \@popfilename
    \@reset@ptions
  }%
  \reserved@a
}
\def\@unknownoptionerror{%
  \@latex@error{%
    Unknown option `\KVO@SanitizedCurrentOption' %
    for \@cls@pkg\space`\@currname'%
  }{%
    The option `\KVO@SanitizedCurrentOption' was not declared in %
    \@cls@pkg\space`\@currname', perhaps you\MessageBreak
    misspelled its name. %
    Try typing \space <return> %
    \space to proceed.%
  }%
}
\def\@@unprocessedoptions{%
  \ifx\@currext\@pkgextension
    \@ifundefined{opt@\@currname.\@currext}{%
      \let\@curroptions\@empty
    }{%
      \expandafter\let\expandafter\@curroptions
          \csname opt@\@currname.\@currext\endcsname
    }%
    \@for\CurrentOption:=\@curroptions\do{%
        \ifx\CurrentOption\@empty\else\@unknownoptionerror\fi
    }%
  \fi
}
\def\KVO@SanitizedCurrentOption{%
  \expandafter\strip@prefix\meaning\CurrentOption
}
\def\KVO@normalize#1#2{%
  \let\KVO@result\@empty
  \KVO@splitcomma#2,\@nil
  \let#1\KVO@result
}
\def\KVO@splitcomma#1,#2\@nil{%
  \KVO@ifempty{#1}{}{%
    \KVO@checkkv#1=\@nil
  }%
  \KVO@ifempty{#2}{}{\KVO@splitcomma#2\@nil}%
}
\def\KVO@ifempty#1{%
  \expandafter\ifx\expandafter\\\detokenize{#1}\\%
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\def\KVO@checkkv#1=#2\@nil{%
  \KVO@ifempty{#2}{%
    % option without value
    \edef\KVO@x{\zap@space#1 \@empty}%
    \ifx\KVO@x\@empty
      % ignore empty option
    \else
      % append to list
      \edef\KVO@result{%
        \etex@unexpanded\expandafter{\KVO@result},\KVO@x
      }%
    \fi
  }{%
    % #1: "key", #2: "value="
    % add key part
    \edef\KVO@result{%
      \etex@unexpanded\expandafter{\KVO@result},%
      \zap@space#1 \@empty
    }%
    \futurelet\@let@token\KVO@checkfirsttok#2 \@nil| = \@nil|\KVO@nil
  }%
}
\def\KVO@checkfirsttok{%
  \ifx\@let@token\bgroup
    % no space at start
    \expandafter\KVO@removelastspace\expandafter=%
    % "<value><spaceopt>= \@nil"
  \else
    \expandafter\KVO@checkfirstA
  \fi
}
\def\KVO@checkfirstA#1 #2\@nil{%
  \KVO@ifempty{#2}{%
    \KVO@removelastspace=#1 \@nil
  }{%
    \KVO@ifempty{#1}{%
      \KVO@removelastspace=#2\@nil
    }{%
      \KVO@removelastspace=#1 #2\@nil
    }%
  }%
}
\def\KVO@removelastspace#1 = \@nil|#2\KVO@nil{%
  \KVO@ifempty{#2}{%
    \edef\KVO@result{%
      \etex@unexpanded\expandafter{\KVO@result}%
      \etex@unexpanded\expandafter{\KVO@removegarbage#1\KVO@nil}%
    }%
  }{%
    \edef\KVO@result{%
      \etex@unexpanded\expandafter{\KVO@result}%
      \etex@unexpanded{#1}%
    }%
  }%
}
\def\KVO@removegarbage#1= \@nil#2\KVO@nil{#1}%
\def\KVO@removeelement#1#2{%
  \begingroup
    \toks@={}%
    \@for\x:=#2\do{%
      \ifx\x\@empty
      \else
        \ifx\x#1\relax
        \else
          \edef\t{\the\toks@}%
          \ifx\t\@empty
          \else
            \toks@\expandafter{\the\toks@,}%
          \fi
          \toks@\expandafter{\the\expandafter\toks@\x}%
        \fi
      \fi
    }%
    \edef\x{\endgroup
      \def\noexpand#2{\the\toks@}%
    }%
  \x
}
\let\@@fileswith@pti@ns\KVO@fileswith@pti@ns
\ifx\@fileswith@pti@ns\@badrequireerror
\else
  \let\@fileswith@pti@ns\KVO@fileswith@pti@ns
\fi
\let\KVO@Patch=Y
\KVO@AtEnd%
\endinput
%%
%% End of file `kvoptions-patch.sty'.
