diff options
author | Karl Berry <karl@freefriends.org> | 2015-03-04 00:12:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-03-04 00:12:30 +0000 |
commit | 54e0055672245bb7a9d7875052b7c2b47038ba76 (patch) | |
tree | a16d0031f6073e6a485013223b01862ce9b0e702 /Master/texmf-dist/tex/latex/multiexpand | |
parent | d34e62f6c5fec68a9b3cb118a1d0bfcee6302726 (diff) |
multiexpand (3mar15)
git-svn-id: svn://tug.org/texlive/trunk@36427 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/multiexpand')
-rw-r--r-- | Master/texmf-dist/tex/latex/multiexpand/multiexpand.sty | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/latex/multiexpand/multiexpand.sty b/Master/texmf-dist/tex/latex/multiexpand/multiexpand.sty index e69945c3c9f..23ef936a250 100644 --- a/Master/texmf-dist/tex/latex/multiexpand/multiexpand.sty +++ b/Master/texmf-dist/tex/latex/multiexpand/multiexpand.sty @@ -13,29 +13,63 @@ %% ---------------------------------------------------------------- %% \begingroup -\catcode`\@=11\relax% -\gdef\ME@use#1{#1}% -\gdef\MultiExpand{\romannumeral\multiexpand}% -\gdef\MultiExpandAfter{\romannumeral\multiexpandafter}% -\xdef\ME@endroman#1{0\noexpand\expandafter\space}% -\xdef\ME@endroman@after#1{0\noexpand\expandafter\space\noexpand\expandafter}% -\long\gdef\multiexpand#1{% - \ifnum#1<2 \expandafter \ME@endroman% - \else \expandafter \ME@use% - \fi% - {\expandafter \multiexpand \expandafter {% - \number\numexpr#1-1\expandafter}}% -}% -\long\gdef\multiexpandafter#1{% - \ifnum#1<2 \expandafter\ME@endroman@after% - \else \expandafter \ME@use% - \fi% - {\expandafter \multiexpandafter \expandafter {% - \number\numexpr#1-1\expandafter}\expandafter}% -}% +\catcode `\@=11 +\gdef \MultiExpand {\romannumeral \multiexpand } +\gdef \MultiExpandAfter {\romannumeral \multiexpandafter } +\expandafter\ifx\csname numexpr\endcsname\relax +\long\gdef\multiexpand@gobble#1{} +\gdef\multiexpand{\multiexpand@aux\multiexpand@} +\gdef\multiexpandafter{\multiexpand@aux\multiexpand@after} +\long \gdef \multiexpand@aux #1#2% + {\expandafter \multiexpand@test \number #2;#1} +\long \gdef \multiexpand@test #1;#2% + {% + \ifnum #1>0 + \multiexpand@reverse #1{?\multiexpand@reverse@end }?;;#2% + \fi + 0 % + } +\gdef \multiexpand@reverse #1#2;% + {\multiexpand@gobble #1\multiexpand@reverse #2;#1} +\gdef \multiexpand@reverse@end #1;?#2#3;#4#50 + {#5\multiexpand@iterate #41#3;} +\gdef \multiexpand@iterate #1#21#3% + {% + \ifx ;#3\multiexpand@end \fi + \ifx 0#3\multiexpand@zero \fi + \expandafter \multiexpand@iterate + \expandafter #1% + \number 1#2% + \ifcase #3 \or 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\fi + #1% + } +\gdef\multiexpand@zero#1#2\number1#3\ifcase#4\fi#5% + {#1\multiexpand@iterate#59#31} +\gdef\multiexpand@end#1#2\ifcase#3\fi#4{#10 } +\gdef\multiexpand@#1;{#1\expandafter;} +\gdef\multiexpand@after#1;{#1\expandafter;\expandafter} +\else +\gdef \multiexpand@ #1;% + {% + \ifnum #1<2 \multiexpand@end \fi + \expandafter \multiexpand@ + \the \numexpr #1-1\expandafter ;% + } +\gdef \multiexpand@after #1;% + {% + \ifnum #1<2 \multiexpand@end \fi + \expandafter \multiexpand@after + \the \numexpr #1-1\expandafter ;\expandafter + } +\gdef \multiexpand@end #1#2#3;{#10#2 } +\long \gdef \multiexpand #1% + {\expandafter \multiexpand@ \the \numexpr #1;} +\long \gdef \multiexpandafter #1% + {\expandafter \multiexpand@after \the \numexpr #1;} +\fi \endgroup %% -%% Copyright (C) 2011-2013 by Bruno Le Floch <blflatex@gmail.com> +%% Copyright (C) 2011-2015 by Bruno Le Floch <blflatex@gmail.com> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License (LPPL), either |