%% %% This is file `etextools.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% etextools.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2009 by Florent Chervet %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either %% version 1.3 of this license or (at your option) any later %% version. The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% %% This work consists of the main source file etextools.dtx %% and the derived files %% etextools.sty, etextools.pdf, etextools.ins, %% and etextools-examples.tex %% %%% etextools : more e-TeX useful tools for LaTeX package writers %%% Florent CHERVET \NeedsTeXFormat{LaTeX2e}[1996/12/01] \ProvidesPackage{etextools} [2009/07/14 v2e e-TeX more useful tools for LaTeX package writers] \csname ettl@onlyonce\endcsname\let\ettl@onlyonce\endinput \RequirePackage{etex,etoolbox} \edef\ettl@restore@space@catcode{\catcode`\ =\the\catcode`\ } \AtEndOfPackage{\ettl@restore@space@catcode \let\ettl@restore@space@catcode\ettl@undefined} \catcode`\ =10 \long\def\ettl@afterelse#1\else#2\fi{\fi#1} \long\def\ettl@afterfi#1\fi{\fi#1} \long\def\ettl@afterfifi#1\fi\fi{\fi\fi#1} \long\def\ettl@afterelsefi#1\else#2\fi\fi{\fi#1} \newcommand*\@gobblescape{\expandafter\@gobble\string} \newcommand\str@gobblescape[1]{\expandafter\deblank\expandafter{% \expandafter\@gobble\detokenize{#1}}} \newcommand*\noexpandcs[1]{\expandafter\noexpand\csname #1\endcsname} \newcommand\noexpandafter{\noexpand\expandafter} \newcommand\expandnext[2]{% \ifx#1\expandnext \ettl@afterelse\expandafter\expandafter\expandafter \expandafter\@expandnext{#2}{\expandafter\expandafter\expandafter} \else\ettl@afterfi\expandafter#1\expandafter{#2} \fi} \long\def\@expandnext#1#2#3{% \ifx#1\expandnext \expandafter\ettl@afterelse\expandafter\expandafter\expandafter \expandafter\@expandnext{#3}{\expandafter#2#2} \else \expandafter\ettl@afterfi#2#1#2{#3} \fi} \newcommand\deblank{} \begingroup\catcode`\&=3% a & as a math shift \long\gdef\deblank#1{\@deblank#1 &} \long\gdef\@deblank#1 #2&{\ifblank{#2}{#1}{#1\@deblank#2 &}} \endgroup \newrobustcmd\xifblank[1]{\begingroup \protected@edef\@xifblank{\endgroup \noexpand\ifblank{#1}% }\@xifblank} \newrobustcmd\xifstrequal[2]{% \begingroup\protected@edef\@tempa{#1}\protected@edef\@tempb{#2}% \ifx\@tempa\@tempb \aftergroup\@firstoftwo \else \aftergroup\@secondoftwo \fi\endgroup} \newcommand\iffirstchar[2]{% \if \expandafter\@car\string#2\relax\@nil\expandafter\@car#1\string\\\@nil \ettl@afterelse\ifblank{#2}\@secondoftwo\@firstoftwo \else \expandafter\@secondoftwo \fi} \newcommand\ifsinglechar[2]{% \expandnext\expandnext\ifblank{\expandafter\@cdr\string#2 \@nil} {\iffirstchar{#1}{#2}} \@secondoftwo} \newcommand\FE@testopt[3]{\ifsinglechar [{#1}{#2#1}{#2[{#3}]{#1}}} \newcommand\FE@ifstar[3]{\ifsinglechar *{#1}{#2}{#3{#1}}} \newrobustcmd*\DeclareCmdListParser[2]{% \@ifdefinable#1 {\expandafter\etextools@defcmdparser\expandafter{#1}{#2}}} \begingroup\catcode`\&=3 \gdef\etextools@defcmdparser#1#2{% \begingroup \def\`##1`{\expandafter\noexpand\csname ##1\endcsname}% \protected@edef\defineparser{\endgroup \long\def#1####1{\noexpand\FE@ifstar{####1} {\`ettl@lst@star\string#1`} {\`ettl@lst@nost\string#1`}}% \long\csdef{ettl@lst@star\string#1}####1{\noexpand\FE@testopt{####1} {\`ettl@lst@star@pt\string#1`}{\noexpand\do}}% \long\csdef{ettl@lst@nost\string#1}####1{\noexpand\FE@testopt{####1} {\`ettl@lst@nost@pt\string#1`}{\noexpand\do}}% \long\csdef{ettl@lst@star@pt\string#1}[####1]####2{% \`ettl@lst\string#1`{####2}{####1}}% \long\csdef{ettl@lst@nost@pt\string#1}[####1]####2{% \noexpandafter\`ettl@lst\string#1`\noexpandafter{####2}{####1}}% \long\csdef{ettl@lst\string#1}####1####2{% \`ettl@lst@\string#1`{####2}####1\unexpanded{#2}&}% \long\csdef{ettl@lst@\string#1}####1####2\unexpanded{#2}####3&{% \noexpand\ifblank{####2} {} {\noexpand\ettl@lst@doitem{####1}{####2}}% \noexpand\ifblank{####3} {\noexpand\ettl@listbreak} {\`ettl@lst@\string#1`{####1}####3}&}% }\defineparser}% \long\gdef\ettl@lst@doitem#1#2{#1{#2}}% \long\gdef\ettl@listbreak#1&{}% \endgroup \DeclareCmdListParser\csvloop{,} \begingroup\catcode`\|=3 \gdef\do{\DeclareCmdListParser\listloop{|}\undef\do}\aftergroup\do \endgroup \newcommand\csvtolist{\@ifstar\star@csvtolist\nost@csvtolist} \def\star@csvtolist#1{\let#1\@empty\csvloop*[{\unexpanded{\listadd#1}}]} \def\nost@csvtolist#1{\let#1\@empty\csvloop[{\unexpanded{\listadd#1}}]} \newcommand\csvtolistadd{\@ifstar\star@csvtolistadd\nost@csvtolistadd} \def\star@csvtolistadd#1#2{\ifblank{#2} {\let#1\@empty}{\csvloop*[{\unexpanded{\listadd#1}}]{#2}}} \def\nost@csvtolistadd#1#2{\ifblank{#2} {\let#1\@empty}{\csvloop[{\unexpanded{\listadd#1}}]{#2}}} \newrobustcmd\listdel[2]{\@listdel\def{#1}{#2}} \newrobustcmd\listgdel[2]{\@listdel\gdef{#2}{#2}} \newrobustcmd\listxdel[2]{\begingroup \protected@edef\@listxdel{\endgroup \unexpanded{\@listdel\gdef#1}{#2}% }\@listxdel} \begingroup\catcode`\|=3\catcode`\&=3 \long\gdef\@listdel#1#2#3{% \begingroup \def\@tempa##1|#3|##2&{##1|##2\@tempb}% \def\@tempb|##1|\@tempb##2|\@tempb{% \ifblank{##2}{\unexpanded{##1}} {\ifblank{##1}{}{\@tempx##1&}}}% \def\@tempx##1&{\expandafter\@tempb\@tempa|##1|\@tempb|#3|&}% \edef\@redef{\endgroup \unexpanded{#1#2}{% ie: \def or \gdef \listmacro \expandafter\@tempx\unexpanded\expandafter{#2}&}% }\@redef}% end of \@listdel \endgroup \begingroup\catcode`\|=3\catcode`\&=3 \gdef\ettl@list@first@item#1|#2&{#1} \gdef\ettl@list@other@item#1|#2&{#2} \gdef\getlistindex#1{\FE@ifstar{#1}{\ettl@getlistindex{}} {\ettl@getlistindex\expandnext}} \gdef\xgetlistindex#1{\FE@ifstar{#1}{\ettl@xgetlistindex{}} {\ettl@xgetlistindex\expandnext}} \gdef\ettl@xgetlistindex#1#2#3{\begingroup \protected@edef\next{\endgroup\unexpanded{\ettl@getlistindex{#1}{#2}}{#3}% }\next} \gdef\ettl@getlistindex#1#2#3{\begingroup#1\ettl@get@list@idx{#3}{#2}{\numexpr1}} \gdef\ettl@get@list@idx#1#2#3{% #1=expanded list, #2=item, #3=index \ifblank{#1}0% the (remainder of) the list is empty {\expandnext\ifstrequal{\ettl@list@first@item#1&}{#2} {\endgroup\edef\indexinlist{\number#3\relax}} {\expandnext\ettl@get@list@idx{\ettl@list@other@item#1&}{#2}{#3+1}}}} \endgroup% catcode group \newcommand\getlistitem[1]{\FE@ifstar{#1}\ettl@getlistitem {\expandnext\ettl@getlistitem}} \begingroup\catcode`\&=3 \long\gdef\ettl@getlistitem#1#2{%#1=listmacro, #2=index \ettl@get@list@item{#1}{\number\numexpr#2}} \long\gdef\ettl@get@list@item#1#2{% \ifblank{#1}{} {\ifnum#2=1 \ettl@afterelsefi \expandonce{\ettl@list@first@item#1&} \else\ifnum#2>0 \ettl@afterfifi \expandnext\ettl@getlistitem{\ettl@list@other@item#1&}{#2-1}% \fi\fi}} \endgroup \endinput %% %% End of file `etextools.sty'.