summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-03-05 00:56:54 +0000
committerKarl Berry <karl@freefriends.org>2012-03-05 00:56:54 +0000
commit1afc2e2fd4f502e0dfdfe5569e7a3781023682be (patch)
tree75806b6f9aaef03af6e097f014ca1192bfbed38b /Master
parente12041c2f616cc1b749ac8ef97a7d7853a9ce7df (diff)
keyreader (4mar12)
git-svn-id: svn://tug.org/texlive/trunk@25563 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/tex/latex/keyreader/keyreader.sty114
1 files changed, 97 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty
index 7db99a9a5d2..782d3db2354 100644
--- a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty
+++ b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty
@@ -182,6 +182,9 @@
\csname @\ifnum\krd@pdfstrcmp{\detokenize{#1}}%
{\detokenize{#2}}=0first\else second\fi oftwo\endcsname
}
+% If we were to use \krdtrimspace for \krdifbraced, then the need
+% for double \romannumeral will cause problems of premature expansion.
+% We need the \romannumeral below to make \krdifbraced expandable:
\def\krdifbraced#1{%
\expandafter\krdswap\expandafter{%
\expandafter{\romannumeral-`\q\krd@ifbraced@a{#1}}%
@@ -464,8 +467,8 @@
}
\endgroup
\krd@setupnormalize{,}
-
-% Redefine \XKV@define@key to heed a complaint about argument grabbing:
+% Redefine \XKV@define@key to heed a complaint about the grabbing
+% of the callback:
\protected\def\XKV@define@key#1{%
\@ifnextchar[{\XKV@d@fine@k@y{#1}}{%
\begingroup
@@ -478,6 +481,53 @@
\XKV@define@default{#1}{#2}%
\expandafter\def\csname\XKV@header#1\endcsname##1{#3}%
}
+% When the key value has doubled hash characters, xkeyval's
+% definition of \XKV@define@cmdkey fails:
+\def\XKV@define@cmdkey#1#2[#3]#4{%
+ \ifXKV@st\XKV@define@default{#2}{#3}\fi
+ \def\XKV@tempa{\expandafter\def\csname\XKV@header#2\endcsname####1}%
+ \begingroup\expandafter\endgroup\expandafter\XKV@tempa\expandafter
+ {\expandafter\edef\csname#1#2\endcsname{\unexpanded{##1}}#4}%
+}
+% Allow macro prefix (mp@) for choice keys:
+\protected\def\define@choicekey{%
+ \XKV@testopta{\XKV@testoptb
+ {\@testopt\XKV@define@choicekey{choice\XKV@header}}}%
+}
+\def\XKV@define@choicekey[#1]#2{%
+ \def\XKV@macropf{#1#2}%
+ \@testopt{\XKV@d@fine@choicekey{#2}}{}%
+}
+\def\XKV@d@fine@choicekey#1[#2]#3{%
+ \XKV@tempa@toks{#2}%
+ \XKV@sp@deflist\XKV@tempa{#3}%
+ \XKV@toks\expandafter{\XKV@tempa}%
+ \@ifnextchar[{\XKV@d@fine@ch@icekey{#1}}{\XKV@d@fine@ch@ic@key{#1}}%
+}
+\def\XKV@d@fine@ch@icekey#1[#2]{%
+ \XKV@define@default{#1}{#2}%
+ \XKV@d@fine@ch@ic@key{#1}%
+}
+\def\XKV@d@fine@ch@ic@key#1{%
+ \edef\reserved@a{\krdnoexpandcsn{\XKV@header#1}}%
+ \krdifbool{XKV@pl}{%
+ \expandafter\XKV@d@f@ne@ch@ic@k@y\reserved@a
+ }{%
+ \expandafter\XKV@d@f@ne@ch@ic@key\reserved@a
+ }%
+}
+\def\XKV@d@f@ne@ch@ic@key#1#2{\XKV@d@f@n@@ch@ic@k@y#1{{#2}}}
+\def\XKV@d@f@ne@ch@ic@k@y#1#2#3{\XKV@d@f@n@@ch@ic@k@y#1{{#2}{#3}}}
+\def\XKV@d@f@n@@ch@ic@k@y#1#2{%
+ \edef#1##1{%
+ \edef\krdnoexpandcsn{\XKV@macropf}{\noexpand\unexpanded{##1}}%
+ \ifXKV@st\noexpand\XKV@sttrue\else\noexpand\XKV@stfalse\fi
+ \ifXKV@pl\noexpand\XKV@pltrue\else\noexpand\XKV@plfalse\fi
+ \noexpand\XKV@checkchoice[\the\XKV@tempa@toks]{##1}{\the\XKV@toks}%
+ }%
+ \def\XKV@tempa{\def#1####1}%
+ \expandafter\XKV@tempa\expandafter{#1{##1}#2}%
+}
\protected\def\XKV@checksanitizea#1#2{%
\XKV@ch@cksanitize{#1}#2=%
\ifin@\else\XKV@ch@cksanitize{#1}#2,\fi
@@ -535,7 +585,7 @@
\expandafter\krd@s@tkeys@a\CurrentOption==\@nil
}%
}
-% \XKV@s@tk@ys is responsible for the inability of
+% I found that \XKV@s@tk@ys is responsible for the inability of
% xkeyval's \setkeys to handle unbalanced conditionals. So
% we redefine it here, but only for \krdsetkeys:
\protected\def\krd@s@tk@ys#1=#2=#3\@nil{%
@@ -591,12 +641,44 @@
}%
}%
}
+% When the key default value has doubled hash characters,
+% then xkeyval's definition of \XKV@default fails:
+\protected\def\XKV@default#1#2\@nil{%
+ \edef\XKV@tempa{\expandafter\@gobble\string#1}%
+ \edef\XKV@tempb{\XKV@header\XKV@tkey}%
+ \@onelevel@sanitize\XKV@tempb
+ \krdifx\XKV@tempa\XKV@tempb{%
+ \begingroup
+ \@namedef{\XKV@header\XKV@tkey}##1{%
+ \toks@{\edef\XKV@tempa{\unexpanded{##1}}}%
+ }%
+ \csname\XKV@header\XKV@tkey @default\endcsname
+ \expandafter\endgroup\the\toks@
+ \krdifcsndef{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@srstate{@\romannumeral\XKV@depth}{}%
+ \expandafter#1\expandafter{\XKV@tempa}\relax
+ \XKV@srstate{}{@\romannumeral\XKV@depth}%
+ }{%
+ \XKV@srstate{@\romannumeral\XKV@depth}{}%
+ \csname\XKV@header\XKV@tkey @default\endcsname\relax
+ \XKV@srstate{}{@\romannumeral\XKV@depth}%
+ }%
+}
\protected\def\krdsetrmkeys{\XKV@testopta{\XKV@testoptc\krd@setrmkeys}}
\protected\def\krd@setrmkeys[#1]{%
\krdexpandargonce{\krd@setkeys[#1]}\XKV@rm
}
% We alias xkeyval's \savekeys to \savevaluekeys:
-\krdnewlet\savevaluekeys\savekeys
+\protected\def\savevaluekeys{\savekeys}
% We split xkeyval's \presetkeys (head and tail) into
% \krdpresetkeys (head only) and \krdpostsetkeys (tail only):
\protected\def\krdpresetkeys{\@testopt\krd@presetkeys{KV}}
@@ -631,12 +713,12 @@
\protected\def\krddefinekeys{%
\begingroup
\endlinechar\m@ne
- \krd@testst{\@testopt\krd@d@finekeys{KRD}}%
+ \krd@testst{\@testopt\krd@definekeys{KV}}%
}
-\protected\def\krd@d@finekeys[#1]#2{%
- \@testopt{\krd@d@f@nekeys{#1}{#2}}{krdmp@}%
+\protected\def\krd@definekeys[#1]#2{%
+ \@testopt{\krd@d@finekeys{#1}{#2}}{krdmp@}%
}
-\protected\def\krd@d@f@nekeys#1#2[#3]#4{%
+\protected\def\krd@d@finekeys#1#2[#3]#4{%
\expandafter\endgroup
\ifkrd@st
\def\krd@keyst{00}%
@@ -711,18 +793,17 @@
\ifnum\key@typenr=\thr@@*\fi
\ifnum\key@typenr>\@ne+\fi
[\key@prefix]{\key@family}%
- \ifnum\key@typenr>\z@
- \ifnum\key@typenr<\thr@@[\macro@prefix]\fi
- \fi
+ \ifnum\key@typenr>\z@[\macro@prefix]\fi
{\key@name}%
\ifnum\key@typenr=\thr@@
[\unexpanded{\krduserinput\krdorder}]%
{\krdexpandonce\krd@altlista}%
\fi
\krdifx\key@default\krd@rej{}{%
- [\expandafter\krdifbraced\expandafter{\key@default}%
- {{{\krdexpandonce\key@default}}}{\krdexpandonce\key@default}]%
- }{%
+ [{\expandafter\krdifbraced\expandafter{\key@default}%
+ {{{\krdexpandonce\key@default}}}{\krdexpandonce\key@default}}]%
+ }%
+ {%
\ifnum\key@typenr=\thr@@
\krdifx\krd@resb\krd@rej{}{\unexpanded{##5}}%
\krd@executealt{########1}{\krdexpandonce\krd@altlistb}%
@@ -730,7 +811,6 @@
\krdifx\krd@resa\krd@rej{}{\unexpanded{##4}}%
\fi
}%
- % Second branch of callback for '+' variants:
\ifnum\key@typenr>\@ne{\noexpand\krd@keyvalerr}\fi
}%
}%
@@ -814,7 +894,7 @@
\krdnewlet\krdExecuteOptions\ExecuteOptionsX
\krdnewlet\krdProcessOptions\ProcessOptionsX
\krdDeclareOption*{\PackageWarning{keyreader}{Unknown option
- '\CurrentOption' ignored.}}
-\krdProcessOptions[KRD]<keyreader>\relax
+ '\CurrentOption' ignored}}
+\krdProcessOptions[KV]<keyreader>\relax
\endinput