| 1 |
%% |
| 2 |
%% This is file `xkvutils.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% xkeyval.dtx (with options: `xkvutils') |
| 8 |
%% |
| 9 |
%% --------------------------------------- |
| 10 |
%% Copyright (C) 2004-2022 Hendri Adriaens |
| 11 |
%% 2025 David Carlisle for latex-package-repositories |
| 12 |
%% --------------------------------------- |
| 13 |
%% |
| 14 |
%% This work may be distributed and/or modified under the |
| 15 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 16 |
%% of this license or (at your option) any later version. |
| 17 |
%% The latest version of this license is in |
| 18 |
%% http://www.latex-project.org/lppl.txt |
| 19 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 20 |
%% version 2003/12/01 or later. |
| 21 |
%% |
| 22 |
%% This work has the LPPL maintenance status "maintained". |
| 23 |
%% |
| 24 |
%% This Current Maintainer of this work is Hendri Adriaens. |
| 25 |
%% |
| 26 |
%% This work consists of the file xkeyval.dtx and derived files |
| 27 |
%% keyval.tex, xkvtxhdr.tex, xkeyval.sty, xkeyval.tex, xkvview.sty, |
| 28 |
%% xkvltxp.sty, xkvutils.tex, pst-xkey.tex, pst-xkey.sty, xkveca.cls, |
| 29 |
%% xkvecb.cls, xkvesa.sty, xkvesb.sty, xkvesc.sty, xkvex1.tex, |
| 30 |
%% xkvex2.tex, xkvex3.tex and xkvex4.tex. |
| 31 |
%% |
| 32 |
%% The following files constitute the xkeyval bundle and must be |
| 33 |
%% distributed as a whole: readme, xkeyval.pdf, keyval.tex, |
| 34 |
%% pst-xkey.sty, pst-xkey.tex, xkeyval.sty, xkeyval.tex, xkvview.sty, |
| 35 |
%% xkvltxp.sty, xkvtxhdr.tex, xkvutils.tex, pst-xkey.dtx and xkeyval.dtx. |
| 36 |
%% |
| 37 |
\csname XKeyValUtilsLoaded\endcsname |
| 38 |
\let\XKeyValUtilsLoaded\endinput |
| 39 |
\edef\XKeyValUtilsCatcodes{% |
| 40 |
\catcode`\noexpand\@\the\catcode`\@\relax |
| 41 |
\let\noexpand\XKeyValUtilsCatcodes\relax |
| 42 |
} |
| 43 |
\catcode`\@=11\relax |
| 44 |
\newtoks\XKV@toks |
| 45 |
\newtoks\XKV@tempa@toks |
| 46 |
\newtoks\XKV@tempb@toks |
| 47 |
\long\def\@firstoftwo#1#2{#1} |
| 48 |
\long\def\@secondoftwo#1#2{#2} |
| 49 |
\long\def\XKV@afterfi#1\fi{\fi#1} |
| 50 |
\long\def\XKV@afterelsefi#1\else#2\fi{\fi#1} |
| 51 |
\ifx\ifcsname\@undefined\XKV@afterelsefi |
| 52 |
\def\XKV@ifundefined#1{% |
| 53 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 54 |
\expandafter\ifx\csname#1\endcsname\relax |
| 55 |
\expandafter\@firstoftwo |
| 56 |
\else |
| 57 |
\expandafter\@secondoftwo |
| 58 |
\fi |
| 59 |
} |
| 60 |
\else |
| 61 |
\def\XKV@ifundefined#1{% |
| 62 |
\ifcsname#1\endcsname |
| 63 |
\expandafter\@secondoftwo |
| 64 |
\else |
| 65 |
\expandafter\@firstoftwo |
| 66 |
\fi |
| 67 |
} |
| 68 |
\fi |
| 69 |
\XKV@ifundefined{[email protected]}{ |
| 70 |
\input keyval |
| 71 |
\expandafter\def\csname [email protected]\endcsname{1999/03/16} |
| 72 |
}{} |
| 73 |
\long\def\@ifnextcharacter#1#2#3{% |
| 74 |
\@ifnextchar\bgroup |
| 75 |
{\@ifnextchar{#1}{#2}{#3}}% |
| 76 |
{\@ifncharacter{#1}{#2}{#3}}% |
| 77 |
} |
| 78 |
\long\def\@ifncharacter#1#2#3#4{% |
| 79 |
\if\string#1\string#4% |
| 80 |
\expandafter\@firstoftwo |
| 81 |
\else |
| 82 |
\expandafter\@secondoftwo |
| 83 |
\fi |
| 84 |
{#2}{#3}#4% |
| 85 |
} |
| 86 |
\long\def\XKV@for@n#1#2#3{% |
| 87 |
\XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}% |
| 88 |
\ifx#2\@empty |
| 89 |
\XKV@for@break |
| 90 |
\else |
| 91 |
\expandafter\XKV@f@r |
| 92 |
\fi |
| 93 |
#2{#3}#1,\@nil,% |
| 94 |
} |
| 95 |
\long\def\XKV@f@r#1#2#3,{% |
| 96 |
\XKV@tempa@toks{#3}\edef#1{\the\XKV@tempa@toks}% |
| 97 |
\ifx#1\@nnil |
| 98 |
\expandafter\@gobbletwo |
| 99 |
\else |
| 100 |
#2\expandafter\XKV@f@r |
| 101 |
\fi |
| 102 |
#1{#2}% |
| 103 |
} |
| 104 |
\long\def\XKV@for@break #1\@nil,{\fi} |
| 105 |
\long\def\XKV@for@o#1{\expandafter\XKV@for@n\expandafter{#1}} |
| 106 |
\long\def\XKV@for@en#1#2#3{\XKV@f@r#2{#3}#1,\@nil,} |
| 107 |
\long\def\XKV@for@eo#1#2#3{% |
| 108 |
\def#2{\XKV@f@r#2{#3}}\expandafter#2#1,\@nil,% |
| 109 |
} |
| 110 |
\long\def\XKV@whilist#1#2#3\fi#4{% |
| 111 |
#3\expandafter\XKV@wh@list#1,\@nil,\@nil\@@#2#3\fi{#4}{}\fi |
| 112 |
} |
| 113 |
\long\def\XKV@wh@list#1,#2\@@#3#4\fi#5#6{% |
| 114 |
\def#3{#1}% |
| 115 |
\ifx#3\@nnil |
| 116 |
\def#3{#6}\expandafter\XKV@wh@l@st |
| 117 |
\else |
| 118 |
#4% |
| 119 |
#5\expandafter\expandafter\expandafter\XKV@wh@list |
| 120 |
\else |
| 121 |
\def#3{#6}\expandafter\expandafter\expandafter\XKV@wh@l@st |
| 122 |
\fi |
| 123 |
\fi |
| 124 |
#2\@@#3#4\fi{#5}{#1}% |
| 125 |
} |
| 126 |
\long\def\XKV@wh@l@st#1\@@#2#3\fi#4#5{} |
| 127 |
\long\def\XKV@addtomacro@n#1#2{% |
| 128 |
\XKV@tempa@toks\expandafter{#1#2}% |
| 129 |
\edef#1{\the\XKV@tempa@toks}% |
| 130 |
} |
| 131 |
\def\XKV@addtomacro@o#1#2{% |
| 132 |
\expandafter\XKV@addtomacro@n\expandafter#1\expandafter{#2}% |
| 133 |
} |
| 134 |
\def\XKV@addtolist@n#1#2{% |
| 135 |
\ifx#1\@empty |
| 136 |
\XKV@addtomacro@n#1{#2}% |
| 137 |
\else |
| 138 |
\XKV@addtomacro@n#1{,#2}% |
| 139 |
\fi |
| 140 |
} |
| 141 |
\def\XKV@addtolist@o#1#2{% |
| 142 |
\ifx#1\@empty |
| 143 |
\XKV@addtomacro@o#1#2% |
| 144 |
\else |
| 145 |
\XKV@addtomacro@o#1{\expandafter,#2}% |
| 146 |
\fi |
| 147 |
} |
| 148 |
\def\XKV@addtolist@x#1#2{\edef#1{#1\ifx#1\@empty\else,\fi#2}} |
| 149 |
\def\@selective@sanitize{\@testopt\@s@lective@sanitize\@M} |
| 150 |
\def\@s@lective@sanitize[#1]#2#3{% |
| 151 |
\begingroup |
| 152 |
\count@#1\relax\advance\count@\@ne |
| 153 |
\XKV@toks\expandafter{#3}% |
| 154 |
\def#3{#2}\@onelevel@sanitize#3% |
| 155 |
\edef#3{{#3}{\the\XKV@toks}}% |
| 156 |
\expandafter\@s@l@ctive@sanitize\expandafter#3#3% |
| 157 |
\expandafter\XKV@tempa@toks\expandafter{#3}% |
| 158 |
\expandafter\endgroup\expandafter\XKV@tempb@toks\expandafter{\the\XKV@tempa@toks}% |
| 159 |
\edef#3{\the\XKV@tempb@toks}% |
| 160 |
} |
| 161 |
\def\@s@l@ctive@sanitize#1#2#3{% |
| 162 |
\def\@i{\futurelet\@@tok\@ii}% |
| 163 |
\def\@ii{% |
| 164 |
\expandafter\@iii\meaning\@@tok\relax |
| 165 |
\ifx\@@tok\@s@l@ctive@sanitize |
| 166 |
\let\@@cmd\@gobble |
| 167 |
\else |
| 168 |
\ifx\@@tok\@sptoken |
| 169 |
\XKV@toks\expandafter{#1}\edef#1{\the\XKV@toks\space}% |
| 170 |
\def\@@cmd{\afterassignment\@i\let\@@tok= }% |
| 171 |
\else |
| 172 |
\let\@@cmd\@iv |
| 173 |
\fi |
| 174 |
\fi |
| 175 |
\@@cmd |
| 176 |
}% |
| 177 |
\def\@iii##1##2\relax{\if##1\@backslashchar\let\@@tok\relax\fi}% |
| 178 |
\def\@iv##1{% |
| 179 |
\toks@\expandafter{#1}\XKV@toks{##1}% |
| 180 |
\ifx\@@tok\bgroup |
| 181 |
\advance\count@\m@ne |
| 182 |
\ifnum\count@>\z@ |
| 183 |
\begingroup |
| 184 |
\def#1{\expandafter\@s@l@ctive@sanitize |
| 185 |
\csname\string#1\endcsname{#2}}% |
| 186 |
\expandafter#1\expandafter{\the\XKV@toks}% |
| 187 |
\XKV@toks\expandafter\expandafter\expandafter |
| 188 |
{\csname\string#1\endcsname}% |
| 189 |
\edef#1{\noexpand\XKV@toks{\the\XKV@toks}}% |
| 190 |
\expandafter\endgroup#1% |
| 191 |
\fi |
| 192 |
\edef#1{\the\toks@{\the\XKV@toks}}% |
| 193 |
\advance\count@\@ne |
| 194 |
\let\@@cmd\@i |
| 195 |
\else |
| 196 |
\edef#1{\expandafter\string\the\XKV@toks}% |
| 197 |
\expandafter\in@\expandafter{#1}{#2}% |
| 198 |
\edef#1{\the\toks@\ifin@#1\else |
| 199 |
\ifx\@@tok\@sptoken\space\else\the\XKV@toks\fi\fi}% |
| 200 |
\edef\@@cmd{\noexpand\@i\ifx\@@tok\@sptoken\the\XKV@toks\fi}% |
| 201 |
\fi |
| 202 |
\@@cmd |
| 203 |
}% |
| 204 |
\let#1\@empty\@i#3\@s@l@ctive@sanitize |
| 205 |
} |
| 206 |
\long\def\XKV@checksanitizea#1#2{% |
| 207 |
\XKV@ch@cksanitize{#1}#2=% |
| 208 |
\ifin@\else\XKV@ch@cksanitize{#1}#2,\fi |
| 209 |
\ifin@\@selective@sanitize[0]{,=}#2\fi |
| 210 |
} |
| 211 |
\def\XKV@checksanitizeb#1#2{% |
| 212 |
\XKV@ch@cksanitize{#1}#2,% |
| 213 |
\ifin@\@selective@sanitize[0],#2\fi |
| 214 |
} |
| 215 |
\long\def\XKV@ch@cksanitize#1#2#3{% |
| 216 |
\XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}% |
| 217 |
\@onelevel@sanitize#2% |
| 218 |
\@expandtwoargs\in@#3{#2}% |
| 219 |
\ifin@ |
| 220 |
\long\def#2##1#3##2\@nil{% |
| 221 |
\XKV@tempa@toks{##2}\edef#2{\the\XKV@tempa@toks}% |
| 222 |
\ifx#2\@empty\else\in@false\fi |
| 223 |
}% |
| 224 |
#2#1#3\@nil |
| 225 |
\fi |
| 226 |
\XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}% |
| 227 |
} |
| 228 |
\def\XKV@sp@deflist#1#2{% |
| 229 |
\let#1\@empty |
| 230 |
\XKV@for@n{#2}\XKV@resa{% |
| 231 |
\expandafter\KV@@sp@def\expandafter\XKV@resa\expandafter{\XKV@resa}% |
| 232 |
\XKV@addtomacro@o#1{\expandafter,\XKV@resa}% |
| 233 |
}% |
| 234 |
\ifx#1\@empty\else |
| 235 |
\def\XKV@resa,##1\@nil{\def#1{##1}}% |
| 236 |
\expandafter\XKV@resa#1\@nil |
| 237 |
\fi |
| 238 |
} |
| 239 |
\def\XKV@merge#1#2#3{% |
| 240 |
\XKV@checksanitizea{#2}\XKV@tempa |
| 241 |
\XKV@for@o\XKV@tempa\XKV@tempa{% |
| 242 |
\XKV@pltrue |
| 243 |
#3\XKV@tempa\XKV@tempb |
| 244 |
\let\XKV@tempc#1% |
| 245 |
\let#1\@empty |
| 246 |
\XKV@for@o\XKV@tempc\XKV@tempc{% |
| 247 |
#3\XKV@tempc\XKV@tempd |
| 248 |
\ifx\XKV@tempb\XKV@tempd |
| 249 |
\XKV@plfalse |
| 250 |
\XKV@addtolist@o#1\XKV@tempa |
| 251 |
\else |
| 252 |
\XKV@addtolist@o#1\XKV@tempc |
| 253 |
\fi |
| 254 |
}% |
| 255 |
\ifXKV@pl\XKV@addtolist@o#1\XKV@tempa\fi |
| 256 |
}% |
| 257 |
\ifXKV@st\global\let#1#1\fi |
| 258 |
} |
| 259 |
\def\XKV@delete#1#2#3{% |
| 260 |
\XKV@checksanitizeb{#2}\XKV@tempa |
| 261 |
\let\XKV@tempb#1% |
| 262 |
\let#1\@empty |
| 263 |
\XKV@for@o\XKV@tempb\XKV@tempb{% |
| 264 |
#3\XKV@tempb\XKV@tempc |
| 265 |
\@expandtwoargs\in@{,\XKV@tempc,}{,\XKV@tempa,}% |
| 266 |
\ifin@\else\XKV@addtolist@o#1\XKV@tempb\fi |
| 267 |
}% |
| 268 |
\ifXKV@st\global\let#1#1\fi |
| 269 |
} |
| 270 |
\XKeyValUtilsCatcodes |
| 271 |
\endinput |
| 272 |
%% |
| 273 |
%% End of file `xkvutils.tex'. |