diff options
author | Karl Berry <karl@freefriends.org> | 2010-12-08 23:10:58 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-12-08 23:10:58 +0000 |
commit | 3a4601dfbb6823b75e830844636ce2e7ef1a23c0 (patch) | |
tree | fbd6becf5a691e5fd1c9a8d17da2e2aca6904070 /Master/texmf-dist/tex/latex/etextools/etextools.sty | |
parent | dc303a1e6f377dc52672a520237e5898ca5d3b37 (diff) |
etextools 3.1415926 (8dec10)
git-svn-id: svn://tug.org/texlive/trunk@20694 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etextools/etextools.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/etextools/etextools.sty | 106 |
1 files changed, 61 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/latex/etextools/etextools.sty b/Master/texmf-dist/tex/latex/etextools/etextools.sty index 485d402da68..cbccdcfecc4 100644 --- a/Master/texmf-dist/tex/latex/etextools/etextools.sty +++ b/Master/texmf-dist/tex/latex/etextools/etextools.sty @@ -19,10 +19,9 @@ %% etextools.sty, etextools.pdf, etextools.ins, %% and etextools-examples.tex %% -%%% etextools : e-TeX tools for LaTeX Users and package Writers (v.3.14159 - 2010/04/20) \NeedsTeXFormat{LaTeX2e}[1996/12/01] \ProvidesPackage{etextools} - [2010/04/20 v3.14159 e-TeX more useful tools for LaTeX package writers] + [2010/12/07 v3.1415926 e-TeX more useful tools for LaTeX package writers] \csname ettl@onlyonce\endcsname\let\ettl@onlyonce\endinput \RequirePackage{etex,etoolbox,letltxmacro} \let\ettl@AtEnd\@empty @@ -78,7 +77,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 @\expandafter\ettl@cdr\detokenize{#1}\@nil @% +\long\def\ettl@char#1{\csname ettl@\ifcat $\expandafter\ettl@cdr\detokenize{#1}\@nil$% 1\else2\fi of2\endcsname} \providecommand*\@intmax{2147483647} \def\ettl@intmax{2147483647} @@ -101,7 +100,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 @\detokenize{#1}@first\else second\fi oftwo\endcsname + \ifcat $\detokenize{#1}$first\else second\fi oftwo\endcsname { #2}{ #3}} % The following macros are not used (here just for memory, in case of...) @@ -166,13 +165,13 @@ \newcommand\ExpandNextTwo[3]{\ExpandNext{\ExpandNext{#1}{#2}}{#3}} % noexpandcs { csname } -\newcommand*\noexpandcs[1]{\expandafter\noexpand\csname #1\endcsname} +\providecommand*\noexpandcs[1]{\expandafter\noexpand\csname #1\endcsname} % noexpandafter \newcommand*\noexpandafter{\noexpand\expandafter} %% \thefontname -\newcommand\thefontname{{\expandafter\expandafter\expandafter\ettl@thefontname +\newcommand\thefontname{\nfss@text{\expandafter\expandafter\expandafter\ettl@thefontname \expandafter\expandafter\expandafter\meaning \expandafter\the\expandafter\font \expandafter\string\expandafter(% @@ -278,8 +277,8 @@ %% \ifsingletoken{ tokenA }{ tokenB }{ true }{ false } \newcommand\ifsingletoken[2]{\romannumeral\csname rmn@\ettl@firstspace{#2} - {\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}@% + {\ettl@nbk#1#2//{second}{\ifcat $\detokenize{#1#2}$first\else\ifx#1#2first\else second\fi\fi}//} + {\ifcat $\detokenize\expandafter{\ettl@cdr#2\@nil}$% \expandafter\ettl@ifxsingle \else\expandafter\ettl@carcar \fi{#1}{#2}{first}{second}}% @@ -291,24 +290,24 @@ \ettl@nbk#2//% {\ettl@nbk#1//% {\expandnexttwo\ettl@ifx{\ettl@car#2\@nil}{\ettl@car#1\@nil}{first}{second}} - {\if @\detokenize{#1}@secondoftwo\ettl@csname\fi + {\ifcat $\detokenize{#1}$secondoftwo\ettl@csname\fi \ettl@firstspace{#2}{first}{second}}//}% {\ettl@nbk#1//% - {\if @\detokenize{#2}@secondoftwo\ettl@csname\fi + {\ifcat $\detokenize{#2}$secondoftwo\ettl@csname\fi \ettl@firstspace{#1}{first}{second}} - {\if @\detokenize{#1#2}@first\else second\fi}}//% + {\ifcat $\detokenize{#1#2}$first\else second\fi}}//% oftwo\endcsname} %% \ifOneToken{ token }{ true }{ false } \newcommand\ifOneToken[1]{\romannumeral\csname rmn@\ettl@firstspace{#1} - {\ettl@nbk#1//{second}{\if @\detokenize{#1}@second\else first\fi}//} - {\if @\detokenize\expandafter{\ettl@cdr#1\@nil}@% + {\ettl@nbk#1//{second}{\ifcat $\detokenize{#1}$second\else first\fi}//} + {\ifcat $\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 @\detokenize{#1#2}@first\else\ifx#1#2first\else second\fi\fi}//} - {\if @\detokenize\expandafter{\ettl@cdr#2\@nil}@% + {\ettl@nbk#2//{second}{\ifcat $\detokenize{#1#2}$first\else\ifx#1#2first\else second\fi\fi}//} + {\ifcat $\detokenize\expandafter{\ettl@cdr#2\@nil}$% \expandafter\ettl@ifchar \else\expandafter\ettl@carcar \fi{#1}{#2}{first}{second}}% @@ -321,8 +320,8 @@ oftwo\endcsname} \else \newcommand\ifOneChar[1]{\romannumeral\csname rmn@\ettl@firstspace{#1} - {\ettl@nbk#1//{second}{\if @\detokenize{#1}@second\else first\fi}//} - {\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @% + {\ettl@nbk#1//{second}{\ifcat $\detokenize{#1}$second\else first\fi}//} + {\ifcat $\expandafter\ettl@cdr\detokenize{#1}\@nil$% first\else second\fi}oftwo\endcsname} \fi%\pdfmatch @@ -343,18 +342,18 @@ \ettl@nbk#2//% {\ettl@nbk#1//% {\expandnexttwo\ettl@ifchar{\ettl@car#2\@nil}{\ettl@car#1\@nil}{first}{second}} - {\if @\detokenize{#1}@secondoftwo\ettl@csname\fi + {\ifcat $\detokenize{#1}$secondoftwo\ettl@csname\fi \ettl@firstspace{#2}{first}{second}}//}% {\ettl@nbk#1//% - {\if @\detokenize{#2}@secondoftwo\ettl@csname\fi + {\ifcat $\detokenize{#2}$secondoftwo\ettl@csname\fi \ettl@firstspace{#1}{first}{second}} - {\if @\detokenize{#1#2}@first\else second\fi}}//% + {\ifcat $\detokenize{#1#2}$first\else second\fi}}//% oftwo\endcsname} %% \ifiscs { string }{ true }{ false } \newcommand\ifiscs[1]{\romannumeral\csname rmn@\ettl@nbk#1//% - {\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @secondoftwo\ettl@csname\fi - \if @\detokenize\expandafter{\ettl@cdr#1\@nil}@% + {\ifcat $\expandafter\ettl@cdr\detokenize{#1}\@nil$secondoftwo\ettl@csname\fi + \ifcat $\detokenize\expandafter{\ettl@cdr#1\@nil}$% \expandafter\ettl@firstspace \else secondoftwo\ettl@csname\fi{#1}{second}{first}} {second}//oftwo\endcsname} @@ -370,11 +369,11 @@ {\expandafter\@swap\expandafter{\romannumeral\ettl@protectspace#2/End^^a7String/}{\z@#1{ }}}} %% \ifempty{ text }{ true }{ false } -\newcommand\ifempty[1]{\romannumeral\csname rmn@\if @\detokenize{#1}@% +\newcommand\ifempty[1]{\romannumeral\csname rmn@\ifcat $\detokenize{#1}$% first\else second\fi oftwo\endcsname} %% \ifnotempty{ text }{ true }{ false } -\newcommand\ifnotempty[1]{\romannumeral\csname rmn@\if @\detokenize{#1}@% +\newcommand\ifnotempty[1]{\romannumeral\csname rmn@\ifcat $\detokenize{#1}$% second\else first\fi oftwo\endcsname} %% \xifempty{ text }{ true }{ false } @@ -543,31 +542,31 @@ %% \FE@testopt{ #1 }{ commands }{ default option } \long\def\ettl@BasicFilter#1#2#3/End^^a7String/{\expandafter\ettl@B@sicFilter #1#3//#2/End^^a7String//End^^a7String/} \long\def\ettl@B@sicFilter#1/#2//#3/End^^a7String/{@\ettl@nbk#3//% - {\if @\detokenize{#1#2}@first\else second\fi} + {\ifcat $\detokenize{#1#2}$first\else second\fi} {second}//oftwo} \newcommand\FE@testopt[3]{\ettl@FE@testopt#1/[/% {#2#1}% {#2[{#3}]{#1}}}%] -\long\def\ettl@FE@testopt#1[#2/#3#{\csname @\if @\detokenize{#1#2}@% +\long\def\ettl@FE@testopt#1[#2/#3#{\csname @\ifcat $\detokenize{#1#2}$% first\else second\fi oftwo\endcsname} %% \FE@ifstar{ #1 } { \StarredMacro }{ \NotStarredMacro } \newcommand\FE@ifstar[3]{\ettl@FE@ifstar#1/*/% {#2}% {#3{#1}}} -\long\def\ettl@FE@ifstar#1*#2/#3#{\csname @\if @\detokenize{#1#2}@% +\long\def\ettl@FE@ifstar#1*#2/#3#{\csname @\ifcat $\detokenize{#1#2}$% first\else second\fi oftwo\endcsname} %% \FE@charequal{ #1 } { \MacroWith= }{ \NormalMacro } % used by the string filters \newcommand\FE@ifcharequal[3]{\ettl@FE@charequal#1/=/% {#2}% {#3{#1}}} -\long\def\ettl@FE@charequal#1=#2/#3#{\csname @\if @\detokenize{#1#2}@% +\long\def\ettl@FE@charequal#1=#2/#3#{\csname @\ifcat $\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}@% +\long\def\ettl@FE@chardot#1.#2/#3#{\csname @\ifcat $\detokenize{#1#2}$% first\else second\fi oftwo\endcsname} %% \FE@ifchar{ <Character> }{ #1 }{ \SpecialFormMacro }{ \NormalMacro } @@ -630,15 +629,20 @@ \expandafter\afterassignment\csname ettl@afterassignment@hook\the\ettl@fter\endcsname} %% \aftergroup@def{ cs-token } -\newrobustcmd\aftergroup@def[1]{% +\newrobustcmd*\aftergroup@def{\@ifstar\aftergroup@defstar\aftergroup@d@f} +\newrobustcmd*\@ftergroup@def[3]{% + \aftergroup#2\aftergroup#3\aftergroup#1% + \aftergroup\global \aftergroup\undef \aftergroup#1} +\newrobustcmd*\aftergroup@defstar[1]{% + \global\expandafter\let\csname ettl@ftergroup@def\the\numexpr\ettl@fter+1\endcsname#1% + \global\advance\ettl@fter\@ne + \expandafter\@ftergroup@def\csname ettl@ftergroup@def\the\ettl@fter\endcsname\let#1} +\newrobustcmd*\aftergroup@d@f[1]{% \let\etex@let@primitive\let \def\let{\global\etex@let@primitive}% - \expandafter\LetLtxMacro\csname ettl@ftergroup@def\number\numexpr\the\ettl@fter+1\endcsname#1% + \expandafter\LetLtxMacro\csname ettl@ftergroup@def\the\numexpr\ettl@fter+1\endcsname#1% \global\advance\ettl@fter\@ne \etex@let@primitive\let=\etex@let@primitive - \aftergroup\LetLtxMacro \aftergroup#1% - \expandafter\aftergroup\csname ettl@ftergroup@def\the\ettl@fter\endcsname - \aftergroup\global \aftergroup\undef - \expandafter\aftergroup\csname ettl@ftergroup@def\the\ettl@fter\endcsname} + \expandafter\@ftergroup@def\csname ettl@ftergroup@def\the\ettl@fter\endcsname\LetLtxMacro#1}% \let\ettl@aftergroup@def\aftergroup@def %---------------------------------------------------------------------------- @@ -646,13 +650,24 @@ \long\def\@ifchar#1#2{\ettl@ifnextchar #1{\@firstoftwo{#2}}} +%% \@char@testopt{ code }{ single token }{ default value }{ single token } + +\newcommand\@char@testopt[4]{\ettl@ifnextchar#2{#1}{#1#2#3#4}} + +%% \@ifnextchardigit{ true }{ false } + +\newrobustcmd\@ifnextchardigit[2]{\begingroup + + \endgroup +}% \@ifnextchardigit + %% \ettl@ifnextchar{ character token }{ true }{ false } \newrobustcmd\ettl@ifnextchar[3]{\begingroup - \edef\1##1/##2/##3{##1\endgroup\unexpanded{#2}##3}% - \edef\2##1/##2/##3{##1\endgroup\unexpanded{#3}##3}% + \long\edef\1##1/##2/##3{##1\endgroup\unexpanded{#2}##3}% + \long\edef\2##1/##2/##3{##1\endgroup\unexpanded{#3}##3}% \ifOneToken{#1} - {\csname ettl@\if @\expandafter\ettl@cdr\detokenize{#1}\@nil @% OneChar + {\csname ettl@\ifcat $\expandafter\ettl@cdr\detokenize{#1}\@nil$% OneChar xifnch\else xifntk\fi\endcsname{#1}} {\2//{}}} \long\def\ettl@xifnch#1{% @@ -660,8 +675,8 @@ \else \def\ettl@xifnch{% \ifx\@let@token\bgroup \2 \else\ifx\@let@token\egroup \2 - \else\ifx\@let@token\@sptoken \ettl@ifnspace\ettl@xifnch% - \else\ettl@ifnch% + \else\ifx\@let@token\@sptoken \ettl@ifnspace\ettl@xifnch + \else\ettl@ifnch \fi\fi\fi/{#1}/{}}% \fi\futurelet\@let@token\ettl@xifnch} \long\def\ettl@ifnch#1/#2/#3{#1\long\def\ettl@ifnch##1{\ettl@char{##1} @@ -690,7 +705,7 @@ {\@ifchar={\ettl@futdef#1\unexpanded} {\@testopt{\ettl@futur@def#1#2}{}}}} \long\def\ettl@futur@def#1#2[#3]{% - \csname ettl@\if @\detokenize{#3}@1\else2\fi of2\endcsname + \csname ettl@\ifcat $\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 @@ -860,10 +875,10 @@ \fi{##4#3//}{\ettl@breakloop{\ifx##10\expandafter\relax\fi}}% }{\ettl@breakloop{}}///End^^a7List/}}% #1\long\def#5##1##2#3##3##4/##5##6##7/End^^a7List/{% - \if @\detokenize{##2}@\expandafter\@gobbletwo\fi\@firstofone{##1{##2}}% + \ifcat $\detokenize{##2}$\expandafter\@gobbletwo\fi\@firstofone{##1{##2}}% ##6{##1}##3##4//{##6}{##7}/End^^a7List/} #1\long\def#6##1##2##3#3##4##5/##6##7##8/End^^a7List/{% - \if @\detokenize{##3}@\expandafter\@gobbletwo\fi\@firstofone{##2[##1]{##3}}% + \ifcat $\detokenize{##3}$\expandafter\@gobbletwo\fi\@firstofone{##2[##1]{##3}}% \expandafter##7\expandafter{\number\numexpr##1+1}{##2}##4##5//{##7}{##8}/End^^a7List/} #1\protected\def#7{\@ifchar*% {\@ifchar+{\ettl@forloop{\expandafter#2\expandafter*\expandafter+}{[####1]####2}} @@ -894,9 +909,10 @@ #1\expandafter[\csname ettl@for@do\the\ettl@for@nested\endcsname]{#3}% \csundef{ettl@for@do\the\ettl@for@nested}% \csundef{ettl@for@loop\the\ettl@for@nested}% - \global\advance\ettl@for@nested\m@ne\relax} + \global\advance\ettl@for@nested\m@ne\relax}% \expandafter\afterassignment\csname ettl@for@loop\the\ettl@for@nested\endcsname - \long\csdef{ettl@for@do\the\ettl@for@nested}#2} + \long\csdef{ettl@for@do\the\ettl@for@nested}#2% +}% \ettl@for@nested %% \csvloop[\command]\csvListMacro |