diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/etextools/etextools.sty | 84 |
1 files changed, 47 insertions, 37 deletions
diff --git a/Master/texmf-dist/tex/latex/etextools/etextools.sty b/Master/texmf-dist/tex/latex/etextools/etextools.sty index bced95b159e..e30fd6819dc 100644 --- a/Master/texmf-dist/tex/latex/etextools/etextools.sty +++ b/Master/texmf-dist/tex/latex/etextools/etextools.sty @@ -21,7 +21,7 @@ %% etextools.sty, etextools.pdf, etextools.ins, %% and etextools-examples.tex %% -%%% etextools : e-TeX tools for LaTeX Users and package Writers (v.3.1) +%%% etextools : e-TeX tools for LaTeX Users and package Writers (v.3.1 - 2009/09/30) \NeedsTeXFormat{LaTeX2e}[1996/12/01] \ProvidesPackage{etextools} [2009/09/30 v3.1 e-TeX more useful tools for LaTeX package writers] @@ -39,6 +39,7 @@ \TMP@EnsureCode{47}{8}% / \TMP@EnsureCode{167}{7}% § \TMP@EnsureCode{164}{7}% ¤ +\TMP@EnsureCode{95}{11}% _ \TMP@EnsureCode{42}{12}% * \TMP@EnsureCode{43}{12}% + \TMP@EnsureCode{45}{12}% - @@ -79,7 +80,7 @@ \long\def\ettl@firstspace#1#2#3{\expandafter\ettl@firstsp@ce\detokenize{#1} \\{#3}{#2}//} \long\def\ettl@firstsp@ce#1 #2\\{\ettl@nbk#1//} \long\def\ettl@csname#1\endcsname{\fi\endcsname}%% useful to get out of \if -\long\def\ettl@char#1{\csname ettl@\if\relax\expandafter\ettl@cdr\detokenize{#1}\@nil\relax +\long\def\ettl@char#1{\csname ettl@\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @% 1\else2\fi of2\endcsname} \providecommand*\@intmax{2147483647} \def\ettl@intmax{2147483647} @@ -102,7 +103,7 @@ \long\def\ettl@nbk #1#2/#3#4#5//{#4} \long\def\ettl@nbk@else#1#2/#3#4#5//#6\else#7\fi{\fi#4} \long\def\ettl@ney#1//#2#3//{\romannumeral 0\csname @% - \if\relax\detokenize{#1}\relax first\else second\fi oftwo\endcsname + \if @\detokenize{#1}@first\else second\fi oftwo\endcsname { #2}{ #3}} % The following macros are not used (here just for memory, in case of...) @@ -136,9 +137,9 @@ {\expandafter@cmds{#2}{\expandafter\expandafter\expandafter}} {\expandafter\@swap\expandafter{#2}{#1}}} \long\def\expandafter@cmds#1#2#3{% - \ifsingletoken\expandafter@cmds{#1} + \ifsingletoken\expandaftercmds{#1} {\expandafter@cmds{#3}{\expandafter#2#2}} - {\@swap#2{#3}{#1}}} + {#2\@swap#2{#3}{#1}}} %% \expandnext : expansion control % level 1 : \expandnext { code }{ control sequences : the first is expanded before code } @@ -268,8 +269,8 @@ %% \ifsingletoken{ tokenA }{ tokenB }{ true }{ false } \newcommand\ifsingletoken[2]{\csname @\ettl@firstspace{#2} - {\ettl@nbk#1#2//{second}{\if\relax\detokenize{#1#2}\relax first\else\ifx#1#2first\else second\fi\fi}//} - {\if\relax\detokenize\expandafter{\ettl@cdr#2\@nil}\relax + {\ettl@nbk#1#2//{second}{\if @\detokenize{#1#2}@first\else\ifx#1#2first\else second\fi\fi}//} + {\if @\detokenize\expandafter{\ettl@cdr#2\@nil}@% \expandafter\ettl@ifxsingle \else\expandafter\ettl@carcar \fi{#1}{#2}{first}{second}}% @@ -278,14 +279,14 @@ %% \ifOneToken{ token }{ true }{ false } \newcommand\ifOneToken[1]{\romannumeral\csname rmn@\ettl@firstspace{#1} - {\ettl@nbk#1//{second}{\if\relax\detokenize{#1}\relax second\else first\fi}//} - {\if\relax\detokenize\expandafter{\ettl@cdr#1\@nil}\relax + {\ettl@nbk#1//{second}{\if @\detokenize{#1}@second\else first\fi}//} + {\if @\detokenize\expandafter{\ettl@cdr#1\@nil}@% first\else second\fi}oftwo\endcsname} %% \ifsinglechar character{ string }{ true }{ false } \long\def\ifsinglechar#1#2{\romannumeral\csname rmn@\ettl@firstspace{#2} - {\ettl@nbk#2//{second}{\if\relax\detokenize{#1#2}\relax first\else\ifx#1#2first\else second\fi\fi}//} - {\if\relax\detokenize\expandafter{\ettl@cdr#2\@nil}\relax + {\ettl@nbk#2//{second}{\if @\detokenize{#1#2}@first\else\ifx#1#2first\else second\fi\fi}//} + {\if @\detokenize\expandafter{\ettl@cdr#2\@nil}@% \expandafter\ettl@ifchar \else\expandafter\ettl@carcar \fi{#1}{#2}{first}{second}}% @@ -298,8 +299,8 @@ oftwo\endcsname} \else \newcommand\ifOneChar[1]{\romannumeral\csname rmn@\ettl@firstspace{#1} - {\ettl@nbk#1//{second}{\if\relax\detokenize{#1}\relax second\else first\fi}//} - {\if\relax\expandafter\ettl@cdr\detokenize{#1}\@nil\relax + {\ettl@nbk#1//{second}{\if @\detokenize{#1}@second\else first\fi}//} + {\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @% first\else second\fi}oftwo\endcsname} \fi%\pdfmatch @@ -320,18 +321,18 @@ \ettl@nbk#2//% {\ettl@nbk#1//% {\expandnexttwo\ettl@ifchar{\ettl@car#2\@nil}{\ettl@car#1\@nil}{first}{second}} - {\if\relax\detokenize{#1}\relax secondoftwo\ettl@csname\fi + {\if @\detokenize{#1}@secondoftwo\ettl@csname\fi \ettl@firstspace{#2}{first}{second}}//}% {\ettl@nbk#1//% - {\if\relax\detokenize{#2}\relax secondoftwo\ettl@csname\fi + {\if @\detokenize{#2}@secondoftwo\ettl@csname\fi \ettl@firstspace{#1}{first}{second}} - {\if\relax\detokenize{#1#2}\relax first\else second\fi}}//% + {\if @\detokenize{#1#2}@first\else second\fi}}//% oftwo\endcsname} %% \ifiscs { string }{ true }{ false } \newcommand\ifiscs[1]{\romannumeral\csname rmn@\ettl@nbk#1//% - {\if\relax\expandafter\ettl@cdr\detokenize{#1}\@nil\relax secondoftwo\ettl@csname\fi - \if\relax\detokenize\expandafter{\ettl@cdr#1\@nil}\relax + {\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @secondoftwo\ettl@csname\fi + \if @\detokenize\expandafter{\ettl@cdr#1\@nil}@% \expandafter\ettl@firstspace \else secondoftwo\ettl@csname\fi{#1}{second}{first}} {second}//oftwo\endcsname} @@ -347,11 +348,11 @@ {\expandafter\@swap\expandafter{\romannumeral\ettl@protectspace#2/End§String/}{\z@#1{ }}}} %% \ifempty{ text }{ true }{ false } -\newcommand\ifempty[1]{\romannumeral\csname rmn@\if\relax\detokenize{#1}\relax +\newcommand\ifempty[1]{\romannumeral\csname rmn@\if @\detokenize{#1}@% first\else second\fi oftwo\endcsname} %% \ifnotempty{ text }{ true }{ false } -\newcommand\ifnotempty[1]{\romannumeral\csname rmn@\if\relax\detokenize{#1}\relax +\newcommand\ifnotempty[1]{\romannumeral\csname rmn@\if @\detokenize{#1}@% second\else first\fi oftwo\endcsname} %% \xifempty{ text }{ true }{ false } @@ -451,8 +452,6 @@ {\ettl@strfilt@mod 5{{#4}{}{#1}}}%+ {\ettl@strfilt\ettl@strfilt@count{#4}{}{#1}[\ettl@intmax]}%! {\ettl@strfilt\ettl@strfilt@equal{#4}{}{#1}[1]}}}% default -\long\def\ettl@ifchardot#1{\csname\ettl@BasicFilter\ettl@ifchardot@filt.#1/End§String/\endcsname} -\long\def\ettl@ifchardot@filt#1.#2/End§String/{#1/#2} \def\ettl@strfilt@mod #1#2#3{% \ifcase#1 \ettl@or\ettl@ifchardot{#3}% {\ettl@strfilt\ettl@strfilt@equal#2} @@ -522,24 +521,32 @@ %% \FE@testopt{ #1 }{ commands }{ default option } \long\def\ettl@BasicFilter#1#2#3/End§String/{\expandafter\ettl@B@sicFilter #1#3//#2/End§String//End§String/} \long\def\ettl@B@sicFilter#1/#2//#3/End§String/{@\ettl@nbk#3//% - {\if\relax\detokenize{#1#2}\relax first\else second\fi} + {\if @\detokenize{#1#2}@first\else second\fi} {second}//oftwo} -\newcommand\FE@testopt[3]{\csname\ettl@BasicFilter\ettl@FE@testopt[#1/End§String/\endcsname +\newcommand\FE@testopt[3]{\ettl@FE@testopt#1/[/% {#2#1}% {#2[{#3}]{#1}}}%] -\long\def\ettl@FE@testopt#1[#2/End§String/{#1/#2} +\long\def\ettl@FE@testopt#1[#2/#3#{\csname @\if @\detokenize{#1#2}@% + first\else second\fi oftwo\endcsname} %% \FE@ifstar{ #1 } { \StarredMacro }{ \NotStarredMacro } -\newcommand\FE@ifstar[3]{\csname\ettl@BasicFilter\ettl@FE@ifstar*#1/End§String/\endcsname +\newcommand\FE@ifstar[3]{\ettl@FE@ifstar#1/*/% {#2}% {#3{#1}}} -\long\def\ettl@FE@ifstar#1*#2/End§String/{#1/#2} +\long\def\ettl@FE@ifstar#1*#2/#3#{\csname @\if @\detokenize{#1#2}@% + first\else second\fi oftwo\endcsname} %% \FE@charequal{ #1 } { \MacroWith= }{ \NormalMacro } % used by the string filters -\newcommand\FE@ifcharequal[3]{\csname\ettl@BasicFilter\ettl@FE@charequal=#1/End§String/\endcsname +\newcommand\FE@ifcharequal[3]{\ettl@FE@charequal#1/=/% {#2}% {#3{#1}}} -\long\def\ettl@FE@charequal#1=#2/End§String/{#1/#2} +\long\def\ettl@FE@charequal#1=#2/#3#{\csname @\if @\detokenize{#1#2}@% + first\else second\fi oftwo\endcsname} + +%% \ettl@strfilt@dot{ #1 } { \MacroWith= }{ \NormalMacro } % used by the string filters +\newcommand\ettl@ifchardot[1]{\ettl@FE@chardot#1/./} +\long\def\ettl@FE@chardot#1.#2/#3#{\csname @\if @\detokenize{#1#2}@% + first\else second\fi oftwo\endcsname} %% \FE@ifchar{ <Character> }{ #1 }{ \SpecialFormMacro }{ \NormalMacro } \newcommand\FE@ifchar[4]{\ifsinglechar{#1}{#2}{#3}{#4{#2}}} @@ -623,7 +630,7 @@ \edef\1##1/##2/##3{##1\endgroup\unexpanded{#2}##3}% \edef\2##1/##2/##3{##1\endgroup\unexpanded{#3}##3}% \ifOneToken{#1} - {\csname ettl@\if\relax\expandafter\ettl@cdr\detokenize{#1}\@nil\relax % OneChar + {\csname ettl@\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @% OneChar xifnch\else xifntk\fi\endcsname{#1}} {\2//{}}} \long\def\ettl@xifnch#1{% @@ -661,7 +668,7 @@ {\@ifchar={\ettl@futdef#1\unexpanded} {\@testopt{\ettl@futur@def#1#2}{}}}} \long\def\ettl@futur@def#1#2[#3]{% - \csname ettl@\if\relax\detokenize{#3}\relax1\else2\fi of2\endcsname + \csname ettl@\if @\detokenize{#3}@1\else2\fi of2\endcsname {\let \ettl@x \@empty \letcs \ettl@futur@def@collect{\@gobblescape#1@collectall}}% {\def \ettl@x {#3}\edef \ettl@y {#2{#3}}% \ifx\ettl@x\ettl@y \let\ettl@y\@gobble @@ -740,12 +747,15 @@ %% \naturalloop [ auxiliary commands (default \do) ]{ n times }{ argument } \newcommand\naturalloop[1]{\FE@testopt{#1}\ettl@naturalloop{\do}} \def\ettl@naturalloop[#1]#2#3{% - \ifnum\numexpr#2>0 \ExpandNext{\ettl@naturall@@p[{#1}]{#2-1}{1}{#3}}{#1[1]{#3}{#3}}% - \else\ettl@fi#3% + \ifnum\numexpr#2>0 \expandafter\@swaparg\expandafter{\romannumeral-`\q#1[0]{#3}{#3}}% + {\ettl@naturall@@p[{#1}]{#2-1}{0}{#3}} + \else\@swap{\unexpanded{#3}}% \fi} \def\ettl@naturall@@p[#1]#2#3#4#5#6\fi{\fi% - \ifnum\numexpr#2>0 \ExpandNext{\ettl@naturall@@p[{#1}]{#2-1}{#3+1}{#4}}{#1[#3+1]{#4}{#5}}% - \else\ettl@fi#5% + \ifnum\numexpr#2>0 \expandafter\@swaparg\expandafter{\romannumeral-`\q% + \expandafter\@swap\expandafter{\expandafter[\number\numexpr#3+1]}{#1}{#4}{#5}}% + {\ettl@naturall@@p[{#1}]{#2-1}{#3+1}{#4}}% + \else\@swap{\unexpanded{#5}}% \fi} %% \ifinttokslist{ item }{ list of tokens }{ true }{ false } @@ -825,10 +835,10 @@ \fi{##4#3//}{\ettl@breakloop{}}% }{\ettl@breakloop{}}///End§List/}}% #1\long\def#5##1##2#3##3##4/##5##6##7/End§List/{% - \if\relax\detokenize{##2}\relax\expandafter\@gobbletwo\fi\@firstofone{##1{##2}}% + \if @\detokenize{##2}@\expandafter\@gobbletwo\fi\@firstofone{##1{##2}}% ##6{##1}##3##4//{##6}{##7}/End§List/} #1\long\def#6##1##2##3#3##4##5/##6##7##8/End§List/{% - \if\relax\detokenize{##3}\relax\expandafter\@gobbletwo\fi\@firstofone{##2[##1]{##3}}% + \if @\detokenize{##3}@\expandafter\@gobbletwo\fi\@firstofone{##2[##1]{##3}}% \expandafter##7\expandafter{\number\numexpr##1+1}{##2}##4##5//{##7}{##8}/End§List/} #1\protected\def#7{\@ifchar*% {\@ifchar+{\ettl@forloop{\expandafter#2\expandafter*\expandafter+}{[####1]####2}} |