From 9435ac9be63f98808cdc3da26b847f59ba65d830 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 13 Jan 2006 00:10:51 +0000
Subject: varindex

git-svn-id: svn://tug.org/texlive/trunk@1435 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/varindex/varindex.sty | 1064 +++++++++++++++++++++
 1 file changed, 1064 insertions(+)
 create mode 100644 Master/texmf-dist/tex/latex/varindex/varindex.sty

(limited to 'Master/texmf-dist/tex/latex/varindex/varindex.sty')

diff --git a/Master/texmf-dist/tex/latex/varindex/varindex.sty b/Master/texmf-dist/tex/latex/varindex/varindex.sty
new file mode 100644
index 00000000000..735478e9ad4
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/varindex/varindex.sty
@@ -0,0 +1,1064 @@
+%%
+%% This file was generated by the docstrip utility from varindex.dtx.
+%% You may distribute this file only together with the source varindex.dtx
+%% (and if possible with varindex.ins) and only if these files are unmodified.
+%%
+%% Author:
+%%
+%% M. V\"ath      vaeth@mathematik.uni-wuerzburg.de
+%%
+
+\ifx\typeout\undefined
+  \def\vx@tmp{\immediate\write17}
+\else
+  \let\vx@tmp\typeout
+\fi\vx@tmp{varindex.sty by M. Vaeth: Release 2.3}
+\ifx\ProvidesPackage\undefined\else
+  \ProvidesPackage{varindex}[2001/05/06 v2.3]
+\fi
+\ifx\RequirePackage\undefined
+  \ifx\toolboxDef\undefined
+    \input toolbox.sty
+  \fi
+  \ifx\toolboxNewifFalse\undefined
+    \errmessage{varindex.sty requires toolbox.sty version 3.1 or higher}
+  \fi
+\else
+  \RequirePackage{toolbox}[2001/05/06]
+\fi
+
+%%
+%% The file starts with the documented (sample) macros with their "sub"macros:
+%%
+
+\ifx\newcommand\undefined\else
+  \newcommand{\varindextwoScan}{}
+  \newcommand{\varindextwo}{}
+  \newcommand{\vxtAddmyStar}{}
+  \newcommand{\vxtMakemyFormat}{}
+\fi
+
+\def\varindextwoScan{%
+  \varindexNewFlag _\vxtSpaceA
+  \varindexNewFlag -\vxtDashA
+  \varindexNewFlag .\vxtDotA
+  \varindexNewFlag <\vxtOmitA
+  \varindexNewFlag /\vxtNoTildeA
+  \varindexNewFlag `\vxtNopropA
+  \varindexNewFlag P\vxtNopropA% Now obsolete; only for backward compatibility
+  \varindexNewFlag ^\vxtBreakifyA
+  \varindexNewFlag ,\vxtCommaB
+  \varindexNewFlag ~\vxtSpaceB
+  \varindexNewFlag +\vxtDashB
+  \varindexNewFlag ;\vxtDotB
+  \varindexNewFlag >\vxtOmitB
+  \varindexNewFlag !\vxtTildeB
+  \varindexNewFlag ?\vxtNoTildeB
+  \varindexNewFlag p\vxtNopropB% Now obsolete; only for backward compatibility
+  \varindexNewFlag '\vxtNopropB
+  \varindexNewFlag =\vxtDashifyB
+  \varindexNewFlag :\vxtOmitifyB
+  \varindexMakeSplitExpand{+}{vxtSplitAtMagic}% + is the magic symbol
+}
+
+\def\varindextwo{%
+  \let\vxtStarFormat\undefined
+  \def\vxtexecute{\let\vxtmyFormat\varindexFormatDefault}%
+  \ifcase\varindexCount
+    % We have 0 entries (this cannot happen: {} generates one (empty) entry)
+  \or% 1 entry:
+    \def\vxtexecute{%
+      \toolboxDef\vxtmyFormat{1}%
+      \toolboxDef\vxtStarFormat{\varindexOutputString 1}}%
+  \or% 2 entries:
+    \def\vxtentryAa{1}%
+    \def\vxtentryAb{2}%
+    \def\vxtentryBa{2}%
+    \def\vxtentryBb{1}%
+    \let\vxtexecute\vxtMakemyFormat
+  \or% 3 entries:
+    \def\vxtentryAa{1}%
+    \ifx\vxtNopropA\undefined
+      \def\vxtentryAb{23}%
+    \else
+      \def\vxtentryAb{3}%
+    \fi
+    \def\vxtentryBa{3}%
+    \ifx\vxtNopropB\undefined
+      \def\vxtentryBb{12}%
+    \else
+      \def\vxtentryBb{1}%
+    \fi
+    \let\vxtexecute\vxtMakemyFormat
+  \or% 4 entries:
+    \def\vxtentryAa{1}%
+    \ifx\vxtNopropA\undefined
+      \def\vxtentryAb{24}%
+    \else
+      \def\vxtentryAb{4}%
+    \fi
+    \def\vxtentryBa{4}%
+    \ifx\vxtNopropB\undefined
+      \def\vxtentryBb{13}%
+    \else
+      \def\vxtentryBb{1}%
+    \fi
+    \let\vxtexecute\vxtMakemyFormat
+  \else% more than 4 entries:
+    \def\vxtexecute{\let\vxtmyFormat\varindexFormatDefault}%
+  \fi
+  \ifvarindexExplicitFormat% the optional format string was given:
+    \expandafter\vxtSplitAtMagic\expandafter{\varindexFormat}\vxttmp\vxttmpa
+    \ifx\vxttmpa\undefined
+      % If the Magic symbol does not occur, we do nothing
+    \else% Otherwise:
+      % We generate our format and insert it at the place of the Magic symbol:
+      \vxtexecute
+      \toolboxDef\varindexFormat{\vxttmp\vxtmyFormat\vxttmpa}%
+      \vxtAddmyStar
+    \fi
+  \else% without an optional format string, we generate our own format
+    \vxtexecute
+    \let\varindexFormat\vxtmyFormat
+    \vxtAddmyStar
+  \fi
+}
+
+\toolboxNewiftrue{varindextwoCommaTilde}
+\toolboxNewiftrue{varindextwoDashTilde}
+\toolboxNewiffalse{varindextwoDashSpace}
+\def\vxtAddmyStar{%
+  \ifvarindexStar% With the * flag, and
+    \ifx\vxtStarFormat\undefined\else% if we have our own StarFormat:
+      \varindexStarfalse% <- No further prepending of `*' desired afterwards
+      \expandafter\varindexSplitAtOutput\expandafter{\varindexFormat}%
+        \vxttmp\vxttmp
+      \ifx\vxttmp\undefined% Did no `*' occur in the format string yet?
+        \ifx\varindexFormat\toolboxEmpty% Empty format means: Only the * part:
+          \let\varindexFormat\vxtStarFormat
+        \else%Normally, we prepend our *-format and a space
+          \toolboxDef\varindexFormat{%
+            \vxtStarFormat\varindexIndexString\varindexFormat}%
+        \fi
+      \fi
+    \fi
+  \fi
+}
+
+\def\vxtMakemyFormat{%
+  \let\vxtstarseparator\toolboxEmpty
+  \ifx\vxtBreakifyA\undefined
+    \ifx\vxtSpaceA\undefined
+      \ifx\vxtDashA\undefined
+        \ifx\vxtDotA\undefined
+          \vxtExclamSeparator
+        \else
+          \let\vxtseparator\varindexOmitString
+          \let\vxtstarseparator\vxtseparator
+        \fi
+      \else
+        \let\vxtseparator\varindexDashString
+        \let\vxtstarseparator\vxtseparator
+      \fi
+    \else
+      \let\vxtseparator\toolboxEmpty
+    \fi
+  \else% With ^
+    \ifx\vxtDotA\undefined
+      \let\vxtstarseparator\varindexDashString
+      \ifx\vxtDashA\undefined% -^
+        \ifvarindextwoDashTilde
+          \vxtExclamSeparator
+          \toolboxAppend\vxtseparator\vxtstarseparator
+        \else
+           \toolboxDef\vxtseparator{\varindexExclamString\vxtstarseparator}%
+        \fi
+      \else% Plain ^
+        \vxtExclamSeparator
+        \ifvarindextwoDashSpace
+          \toolboxDef\vxtseparator{\vxtstarseparator\vxtseparator}%
+        \else
+          \toolboxDef\vxtseparator{%
+            \vxtstarseparator\vxtseparator\varindexOmitString}%
+        \fi
+      \fi
+    \else% .^
+      \let\vxtstarseparator\varindexOmitString
+      \vxtExclamSeparator
+      \toolboxAppend\vxtseparator\vxtstarseparator
+    \fi
+  \fi
+  \ifx\vxtOmitA\undefined
+    % We define now the string "\vxtentryAa?\vxtentryAb" where
+    % ? is determined by the flags.
+    \toolboxDef\vxtmyFormat{\vxtentryAa\vxtseparator\vxtentryAb}%
+  \else
+    \let\vxtmyFormat\toolboxEmpty
+  \fi
+  % The *-format is calculated similarly:
+  \toolboxDef\vxtStarFormat{\varindexOutputString
+    \vxtentryAa\vxtstarseparator\vxtentryAb}%
+  \ifx\vxtOmitB\undefined
+    \let\vxtappend\toolboxEmpty
+    \ifx\vxtSpaceB\undefined
+      \ifx\vxtDashB\undefined
+        \ifx\vxtDotB\undefined
+          \ifx\vxtCommaB\undefined
+            \let\vxtseparator\varindexExclamString
+            \let\vxtappend\varindexTildeAString
+          \else
+            \let\vxtseparator\varindexCommaString
+            \ifvarindextwoCommaTilde
+              \let\vxtappend\varindexTildeAString
+            \fi
+          \fi
+          \ifx\vxtDashifyB\undefined
+            \ifx\vxtOmitifyB\undefined\else
+              \toolboxDef\vxtappend{\varindexOmitString\vxtappend}%
+            \fi
+          \else
+            \toolboxDef\vxtappend{\varindexDashString\vxtappend}%
+          \fi
+        \else
+          \let\vxtseparator\varindexOmitString
+        \fi
+      \else
+        \let\vxtseparator\varindexDashString
+      \fi
+    \else
+      \let\vxtseparator\toolboxEmpty
+    \fi
+    \ifx\vxtTildeB\undefined\else
+      \let\vxtappend\varindexTildeAString
+    \fi
+    \ifx\vxtNoTildeB\undefined\else
+      \let\vxtappend\toolboxEmpty
+    \fi
+    % In all cases, we prepend now the string "\vxtentryBa?\vxtentryBb??"
+    % where ? and ?? are determined by the flags
+    \ifx\vxtmyFormat\toolboxEmpty% If the previous string was empty: no space
+      \toolboxDef\vxtmyFormat{\vxtentryBa\vxtseparator\vxtentryBb\vxtappend}%
+    \else
+      \toolboxAppend\vxtmyFormat{%
+        \varindexIndexString\vxtentryBa\vxtseparator\vxtentryBb\vxtappend}%
+    \fi
+  \fi
+}
+\def\vxtExclamSeparator{%
+  \ifx\vxtNoTildeA\undefined
+    \toolboxDef\vxtseparator{\varindexExclamString\varindexTildeAString}%
+  \else
+    \let\vxtseparator\varindexExclamString
+  \fi}
+
+%% --------------------------------------------------------------------
+%%
+%% Now the implementation of \varindex.
+%%
+
+\ifx\varindexCount\undefined
+  \newcount\varindexCount
+\fi
+
+\toolboxIf\undefined\def\varindexPlaceholderAText{$\sim$}
+\toolboxIf\undefined\let\varindexPlaceholderASort\toolboxEmpty
+\toolboxIf\undefined\def\varindexPlaceholderBText{$\approx$}
+\toolboxIf\undefined\let\varindexPlaceholderBSort\toolboxEmpty
+
+\toolboxNewiftrue{varindexUsePlaceholderA}
+\toolboxNewiftrue{varindexUsePlaceholderB}
+\toolboxNewiftrue{varindexLeadingPlaceholderA}
+\toolboxNewiftrue{varindexLeadingPlaceholderB}
+\toolboxNewiftrue{varindexCommaLeads}
+\toolboxNewiftrue{varindexCommaExpand}
+\toolboxNewiffalse{varindexPreviousAText}
+\toolboxNewiffalse{varindexPreviousASort}
+\toolboxNewiffalse{varindexPreviousBText}
+\toolboxNewiffalse{varindexPreviousBSort}
+\toolboxNewiftrue{varindexEliminateInnerBrace}
+\toolboxNewiftrue{varindexEliminateOuterBrace}
+
+\ifx\newcommand\undefined\else
+  \newcommand{\varindex}{}
+  \newcommand{\varindexNewFlag}{}
+  \newcommand{\varindexTestAndExec}{}
+  \newcommand{\varindexSkipAndExec}{}
+  \newcommand{\varindexSkipDefault}{}
+  \newcommand{\varindexSkipTricky}{}
+  \newcommand{\varindexMakeVarSplit}{}
+  \newcommand{\varindexMakeSplitExpand}{}
+  \newcommand{\varindexSetWordString}{}
+  \newcommand{\varindexSetSortString}{}
+  \newcommand{\varindexSetPlainString}{}
+  \newcommand{\varindexSetIndexString}{}
+  \newcommand{\varindexSetOutputString}{}
+  \newcommand{\varindexSetTildeAString}{}
+  \newcommand{\varindexSetTildeBString}{}
+  \newcommand{\varindexSetSpaceString}{}
+  \newcommand{\varindexSetSpaceTokString}{}
+  \newcommand{\varindexSetOmitString}{}
+  \newcommand{\varindexSetCommaString}{}
+  \newcommand{\varindexSetDashString}{}
+  \newcommand{\varindexSetExclamString}{}
+  \newcommand{\varindexSetStringForNr}{}
+  \newcommand{\varindexedef}{}
+  \newcommand{\varindexArgumentSpace}{}
+  \newcommand{\varindexNewFormat}{}
+  \newcommand{\varindexTokensOut}{}
+  \newcommand{\varindexTokensOutExpand}{}
+  \newcommand{\varindexAddNumber}{}
+  \newcommand{\varindexAddComma}{}
+  \newcommand{\varindexAddTildeA}{}
+  \newcommand{\varindexAddTildeB}{}
+  \newcommand{\varindexAddExclam}{}
+  \newcommand{\varindexAddSpace}{}
+  \newcommand{\varindexAddSpTok}{}
+  \newcommand{\varindexAddOmit}{}
+  \newcommand{\varindexAddDash}{}
+  \newcommand{\varindexDoConvert}{}
+  \newcommand{\varindexNoConvert}{}
+%% Obsolete names (only provided for backward compatibility):
+  \newcommand{\varindexdef}{}
+  \newcommand{\varindexspace}{}
+  \newcommand{\varindexDropBrace}{}
+  \newcommand{\varindexMakeSplit}{}
+  \newcommand{\varindexLet}{}
+  \newcommand{\varindexWithNr}{}
+\fi
+\let\varindexdef\toolboxDef
+\let\varindexspace\toolboxSpace
+\let\varindexDropBrace\toolboxDropBrace
+\let\varindexMakeSplit\toolboxMakeSplit
+\let\varindexLet\toolboxLet
+\let\varindexWithNr\toolboxWithNr
+
+\def\varindex{\begingroup
+  \toolboxNewifFalse{varindexStar}%
+  \toolboxNewifFalse{varindexExplicitFormat}%
+  \toolboxNewifFalse{vx@atespace}%
+  \toolboxNewifFalse{vx@savespace}%
+  \toolboxNewifFalse{vx@ffound}%
+  \toolboxNewifTrue{varindexIndexMode}%
+  \toolboxNewifFalse{varindexSpaceText}%
+  \toolboxNewifFalse{varindexSpaceSort}%
+  \toolboxNewifTrue{vx@firstiter}%
+  \toolboxNewifFalse{vx@tildeLead}%
+  \toolboxNewifFalse{vx@commaTextLead}%
+  \toolboxNewifFalse{vx@commaSortLead}%
+  \varindexCount=0\relax
+  \let\varindexStyle\toolboxEmpty
+  \let\varindexAppend\toolboxEmpty
+  \let\vx@text\toolboxEmpty
+  \let\vx@mainprogram\undefined
+  \let\vx@formatA\undefined
+  \let\vx@formatAstar\undefined
+  \let\varindexFormat\undefined
+  \let\varindexFormatDefault\undefined
+  \varindexNewFlag 1\varindexOneEntry
+  \varindexNewFlag *\varindexStarPos
+  \varindexTestAndExec(%optional formatA)
+    \vx@ReadFormatA%else
+    \vx@TestTextStyle}
+
+\def\vx@ReadFormatA(#1){%
+  \def\vx@formatA{#1}%
+  \varindexTestAndExec(%optional formatAstar)
+    \vx@ReadFormatAstar%else
+    \vx@SkipAndReadScan}
+
+\def\vx@ReadFormatAstar(#1){%
+  \def\vx@formatAstar{#1}\vx@SkipAndReadScan}
+
+\def\vx@SkipAndReadScan{\varindexSkipAndExec\vx@ReadScan}
+\def\vx@ReadScan#1{#1\toolboxEmpty\varindexSkipAndExec\vx@ReadProgram}
+\def\vx@ReadProgram#1{\def\vx@mainprogram{#1}\vx@TestTextStyle}
+
+\def\vx@TestTextStyle{%
+  \varindexTestAndExec[%textstyle]
+    \vx@ReadTextStyle%else
+    \vx@TestFlags}
+
+\def\vx@ReadTextStyle[#1]{%
+  \def\varindexStyle{#1}%
+  \varindexTestAndExec[%pagestyleA]
+    \vx@ReadPageStyleA%else
+    \vx@TestFlags}
+
+\def\vx@ReadPageStyleA[#1]{\def\varindexAppend{#1}\vx@TestFlags}
+
+\def\vx@TestFlags{%
+  \varindexCount=0\relax
+  \varindexEndOfFlag}
+
+\varindexCount=0\relax
+\expandafter
+\def\expandafter\varindexEndOfFlag\expandafter{%
+  \csname vx@TestFlag\the\varindexCount\endcsname}
+\expandafter
+\def\varindexEndOfFlag{\varindexSkipAndExec\vx@ReadMain}%
+\def\varindexNewFlag#1#2{%
+  \let#2\undefined
+  \expandafter
+  \def\expandafter\vx@tmp\expandafter{%
+    \csname vx@TestFlag\the\varindexCount\endcsname #1#2}%
+  \advance\varindexCount by 1\relax
+  \expandafter
+    \toolboxSurround\expandafter{%
+      \csname vx@TestFlag\the\varindexCount\expandafter\endcsname
+      \csname vx@ReadFlag\the\varindexCount\endcsname}{}\vx@tmp
+  \varindexTestAndExec[%program]
+    \vx@ReadFlagProgram%else
+    {\vx@MakeFlagProgram\varindexEndOfFlag}%
+}
+\def\vx@ReadFlagProgram[#1]{\vx@MakeFlagProgram{#1}}
+\def\vx@MakeFlagProgram#1{\expandafter\vx@MakeNewFlag\vx@tmp{#1}}
+
+\def\vx@MakeNewFlag#1#2#3#4#5#6{%
+  \def\varindexEndOfFlag{#1}%
+  \def#1{\varindexTestAndExec#4{#2}{#3}}%
+  \def#2#4{\expandafter
+    \def\expandafter#5\expandafter{\the\varindexCount}%
+    \advance\varindexCount by 1\relax
+    \varindexSkipAndExec{#6}}%
+}
+
+\long\def\vx@ReadMain#1{\def\vx@text{#1}%
+  \ifx\vx@formatA\undefined
+    \def\vx@exec{\varindexSkipAndExec\vx@ReadFormatB}%
+  \else
+    \def\vx@exec{%
+      \varindexTestAndExec[%FormatB]
+        \vx@ReadOptFormatB%else
+        {\ifvx@atespace\vx@savespacetrue\fi\vx@TestAppend}}%
+  \fi
+  \vx@exec}
+
+\def\vx@ReadFormatB#1{\def\varindexFormat{#1}\vx@TestAppend}
+\def\vx@ReadOptFormatB[#1]{\def\varindexFormat{#1}\vx@TestAppend}
+
+\def\vx@TestAppend{%
+  \varindexTestAndExec[%Append]
+    {\vx@savespacefalse\vx@ReadAppend}%else
+    {\ifvx@atespace\vx@savespacetrue\fi\vx@Main}}
+
+\def\vx@ReadAppend[#1]{\def\varindexAppend{#1}\vx@Main}
+
+\def\varindexTestAndExec#1#2#3{%
+  \varindexSkipAndExec{%
+    \ifx\varindexNextToken#1%
+      \def\vx@exec{#2}%
+    \else
+      \def\vx@exec{#3}%
+    \fi
+    \vx@exec}}
+
+\def\varindexSkipAndExec#1{%
+  \vx@atespacefalse
+  \def\vx@skipexec{#1}%
+  \varindexArgumentSpace}
+
+\def\varindexSkipDefault{\futurelet\varindexNextToken\vx@skipexec}
+
+\def\varindexSkipTricky{%
+  \vx@MakeSpaceOther\futurelet\varindexNextToken\vx@SkipLoopTest}
+\def\vx@SkipLoopTest{%
+  \vx@MakeSpaceSpace
+  \ifx\varindexNextToken\vx@spaceothertok
+    \def\vx@skipnext{\vx@gobblespace a}%
+  \else
+    \let\vx@skipnext\vx@skipexec
+  \fi
+  \vx@skipnext}
+\def\vx@gobblespace a#1{\vx@atespacetrue\varindexSkipTricky}
+
+\def\vx@Main{%
+  \ifx\varindexStarPos\undefined
+    \varindexStarfalse
+  \else
+    \varindexStartrue
+  \fi
+  \ifx\vx@formatA\undefined
+    \let\varindexFormatDefault\toolboxEmpty
+  \else
+    \ifvarindexStar
+      \ifx\vx@formatAstar\undefined
+        \let\varindexFormatDefault\vx@formatA
+      \else
+        \let\varindexFormatDefault\vx@formatAstar
+      \fi
+    \else
+      \let\varindexFormatDefault\vx@formatA
+    \fi
+  \fi
+  \toolboxDef\vx@toparse{\vx@text\vx@word\vx@endparse}%
+  \ifx\varindexOneEntry\undefined
+    \varindexCount=0\relax
+    \let\vx@NextLoop\vx@TextLoop
+    \vx@TextLoop
+  \else
+    \varindexCount=1\relax
+    \ifvarindexEliminateOuterBrace
+      \toolboxDropBrace\vx@text
+    \fi
+    \expandafter\vx@TextEntry\expandafter{\vx@text}%
+  \fi
+  \expandafter
+  \def\expandafter\varindexLastEntry\expandafter{\the\varindexCount}%
+  \varindexedef\varindexFormatDefault{\varindexFormatDefault}%
+  \ifx\varindexFormat\undefined
+    \varindexExplicitFormatfalse
+    \let\varindexFormat\varindexFormatDefault
+  \else
+    \varindexExplicitFormattrue
+    \varindexedef\varindexFormat{\varindexFormat}%
+  \fi
+  \ifx\vx@mainprogram\undefined\else
+    \vx@mainprogram
+    \varindexedef\varindexFormat{\varindexFormat}%
+  \fi
+  \ifvarindexStar
+    \expandafter\varindexSplitAtOutput\expandafter{\varindexFormat}\vx@fa\vx@fb
+    \ifx\vx@fb\undefined
+      \expandafter\varindexSplitAtIndex\expandafter{\varindexFormat}%
+        \vx@fa\vx@fb
+      \ifx\vx@fb\undefined
+        \let\vx@fa\undefined
+      \fi
+      \ifx\vx@fa\toolboxEmpty
+        \toolboxDef\varindexFormat{\varindexOutputString\varindexFormat}%
+      \else
+        \toolboxDef\varindexFormat{%
+          \varindexOutputString\varindexIndexString\varindexFormat}%
+      \fi
+    \fi
+  \fi
+  \ifx\varindexFormat\varindexOutputString
+    \toolboxDef\varindexFormat{\varindexOutputString\varindexIndexString}%
+  \fi
+  \ifx\varindexFormat\toolboxEmpty
+    \vx@FormatAll
+  \else
+    \toolboxDef\vx@toparse{\varindexFormat\varindexIndexString\vx@endparse}%
+    \let\vx@NextLoop\vx@FormLoop
+    \vx@FormLoop
+  \fi
+  \ifvx@savespace\aftergroup\space\fi
+\endgroup}
+\def\vx@endparse{\vx@endparse}
+
+\def\vx@TextLoop{%
+  \ifx\vx@toparse\vx@endparse
+    \let\vx@NextLoop\toolboxEmpty
+  \else
+    \advance\varindexCount by 1\relax
+    \expandafter\vx@SplitAtWord\expandafter{\vx@toparse}%
+      \vx@textentry\vx@toparse
+    \ifvarindexEliminateOuterBrace
+      \toolboxDropBrace\vx@textentry
+    \fi
+    \expandafter\vx@TextEntry\expandafter{\vx@textentry}%
+  \fi
+  \vx@NextLoop}
+
+\def\vx@FormLoop{%
+  \ifx\vx@toparse\vx@endparse
+    \let\vx@NextLoop\toolboxEmpty
+  \else
+    \expandafter\varindexSplitAtIndex\expandafter{\vx@toparse}\vx@fa\vx@fb
+    \expandafter\varindexSplitAtOutput\expandafter{\vx@fa}\vx@fa\vx@fc
+    \ifx\vx@fa\toolboxEmpty
+      \ifvx@firstiter%%       In the first iteration,
+%%      \ifx\vx@fc\undefined% if 'space' is the very first sign,
+%%        \vx@FormatAll%      we output everything
+%%      \fi
+      \else
+        \vx@FormatAll
+      \fi
+    \else
+      \expandafter\vx@Format\expandafter{\vx@fa}%
+    \fi
+    \vx@firstiterfalse
+    \ifx\vx@fc\undefined
+      \varindexIndexModetrue
+      \let\vx@toparse\vx@fb
+    \else
+      \varindexIndexModefalse
+      \expandafter
+      \varindexSplitAtOutput\expandafter{\vx@toparse}\vx@fa\vx@toparse
+    \fi
+  \fi
+  \vx@NextLoop}
+
+\def\vx@FormatAll{%
+  \vx@FormatInit
+  \expandafter
+  \def\expandafter\vx@Count\expandafter{\the\varindexCount}\relax
+  \varindexCount=0\relax
+  \let\vx@NextFormatAllLoop\vx@FormatAllLoop
+  \vx@FormatAllLoop
+  \expandafter\varindexCount\expandafter=\vx@Count\relax
+  \vx@Write}
+
+\def\vx@FormatAllLoop{%
+  \advance\varindexCount by 1\relax
+  \expandafter
+  \varindexAddNumber\expandafter{\the\varindexCount}%
+  \expandafter
+  \ifnum\varindexLastEntry=\varindexCount
+    \let\vx@NextFormatAllLoop\toolboxEmpty
+  \fi
+  \vx@NextFormatAllLoop}
+
+\def\vx@AppendWithCount#1#2{%
+  \toolboxLet\vx@tmp{#2\the\varindexCount}%
+  \ifx#1\toolboxEmpty
+    \let#1\vx@tmp
+  \else
+    \ifx\vx@tmp\toolboxEmpty\else\toolboxAppend#1{\toolboxSpace\vx@tmp}\fi
+  \fi}
+
+\def\vx@Format#1{%
+  \vx@FormatInit
+  \def\vx@fparse{#1}%
+  \toolboxAppend\vx@fparse\vx@endparse
+  \let\vx@FormatNextLoop\vx@FormatLoop
+  \vx@FormatLoop
+  \vx@Write
+}
+
+\def\vx@FormatInit{%
+  \let\vx@outputlist\toolboxEmpty
+  \let\vx@textlist\toolboxEmpty
+  \let\vx@sortlist\toolboxEmpty
+  \let\vx@textlistBefore\toolboxEmpty
+  \let\vx@sortlistBefore\toolboxEmpty
+  \let\vx@tildeAText\varindexPlaceholderAText
+  \let\vx@tildeASort\varindexPlaceholderASort
+  \let\vx@tildeBText\varindexPlaceholderBText
+  \let\vx@tildeBSort\varindexPlaceholderBSort
+  \vx@tildeLeadtrue
+  \ifvarindexCommaExpand
+    \vx@commaTextLeadtrue
+    \vx@commaSortLeadtrue
+  \else
+    \vx@commaTextLeadfalse
+    \vx@commaSortLeadfalse
+  \fi
+  \varindexNoNextSpace
+}
+
+\def\vx@FormatLoop{%
+  \vx@ffoundfalse
+  \ifx\vx@fparse\vx@endparse
+    \let\vx@FormatNextLoop\toolboxEmpty
+  \else
+    \vx@HandleFormat
+    \ifvx@ffound\else
+      \expandafter\vx@ErrorFormat\vx@fparse
+      \let\vx@FormatNextLoop\toolboxEmpty
+    \fi
+  \fi
+  \vx@FormatNextLoop
+}
+
+\def\vx@condexec#1#2{\ifvx@ffound\else
+  \expandafter #1\expandafter{\vx@fparse}\vx@fparseA\vx@fparseB
+  \ifx\vx@fparseB\undefined\else
+    \ifx\vx@fparseA\toolboxEmpty
+      \let\vx@fparse\vx@fparseB
+      \vx@ffoundtrue
+      #2%
+    \fi
+  \fi
+\fi}
+
+\let\vx@HandleFormat\toolboxEmpty
+
+\def\varindexNewFormat#1#2{%
+  \toolboxSurround{\vx@condexec{#1}{#2}}{}\vx@HandleFormat}
+
+%% This macro is executed near the end of this file.
+\def\varindexAddOmit{% The name is a fake: The macro redefines this macro
+  \vx@NewStdFormat\varindexSplitAtSpace{Space}%
+  \vx@NewStdFormat\varindexSplitAtSpaceTok{SpTok}%
+  \vx@NewStdFormat\varindexSplitAtOmit{Omit}%
+  \varindexNewFormat\varindexSplitSpace{}% Spaces in inner format are ignored
+  \varindexNewFormat\varindexSplitAtDash\varindexAddDash
+  \varindexNewFormat\varindexSplitAtTildeB\varindexAddTildeB
+  \varindexNewFormat\varindexSplitAtTildeA\varindexAddTildeA
+  \varindexNewFormat\varindexSplitAtComma\varindexAddComma
+  \varindexNewFormat\varindexSplitAtExclam\varindexAddExclam
+  \let\vx@NewStdFormat\undefined% We do not need this generic macro anymore
+}
+
+\def\vx@NewStdFormat#1#2{%
+  \expandafter
+  \varindexNewFormat\expandafter#1\csname varindexAdd#2\endcsname
+  \expandafter
+  \def\expandafter\vx@tmp\expandafter{%
+    \csname varindexPreceeds#2\expandafter\endcsname
+    \expandafter
+    \varindexTokensOutExpand
+      \csname varindexOutText#2\expandafter\endcsname
+      \csname varindexOutSort#2\expandafter\endcsname
+    \csname varindexFollows#2\endcsname}
+  \expandafter\let\csname varindexAdd#2\endcsname\vx@tmp}
+
+\def\varindexAddNumber#1{%
+  \ifnum\varindexCount<#1%
+    \expandafter\vx@ErrorNumber\expandafter{\the\varindexCount}{#1}%
+  \fi
+  \ifvarindexIndexMode
+    \toolboxLet\vx@adda{varindexEntry#1}%
+    \toolboxLet\vx@addb{varindexSort#1}%
+  \else
+    \toolboxLet\vx@adda{varindexPlain#1}%
+  \fi
+  \vx@Addit\varindexSpaceTexttrue\varindexSpaceSorttrue}
+
+\def\varindexAddDash{%
+  \varindexPreceedsDash
+  \ifx\vx@sortlist\toolboxEmpty
+    \varindexTokensOutExpand\varindexOutTextDash\varindexOutSortDashBeg
+  \else
+    \varindexTokensOutExpand\varindexOutTextDash\varindexOutSortDash
+  \fi
+  \varindexFollowsDash}
+
+\def\varindexAddComma{%
+  \ifvarindexCommaLeads
+    \vx@tildeLeadtrue
+  \fi
+  \ifvarindexCommaExpand
+    \let\vx@tildeAText\vx@textlist
+    \let\vx@tildeBText\vx@textlist
+    \ifvarindexIndexMode
+      \let\vx@tildeASort\vx@sortlist
+      \let\vx@tildeBSort\vx@sortlist
+    \fi
+  \fi
+  \varindexPreceedsComma
+  \varindexTokensOutExpand\varindexOutTextComma\varindexOutSortComma
+  \vx@flushToBefore
+  \ifvarindexCommaExpand
+    \vx@commaTextLeadtrue\vx@commaSortLeadtrue
+  \fi
+  \varindexFollowsComma}
+
+\def\vx@flushToBefore{%
+  \ifvarindexCommaExpand
+    \toolboxAppend\vx@textlistBefore\vx@textlist
+    \let\vx@textlist\toolboxEmpty
+    \ifvarindexIndexMode
+      \toolboxAppend\vx@sortlistBefore\vx@sortlist
+      \let\vx@sortlist\toolboxEmpty
+    \fi
+  \fi}
+
+\def\varindexAddTildeA{%
+  \ifvarindexUsePlaceholderA
+    \ifvx@tildeLead
+      \ifvarindexLeadingPlaceholderA
+        \vx@AddingTildeA
+      \fi
+    \else
+      \vx@AddingTildeA
+    \fi
+  \fi}
+\def\vx@AddingTildeA{%
+  \ifvarindexPreviousAText
+    \let\vx@adda\vx@tildeAText
+  \else
+    \let\vx@adda\varindexPlaceholderAText
+  \fi
+  \ifvarindexPreviousASort
+    \let\vx@addb\vx@tildeASort
+  \else
+    \let\vx@addb\varindexPlaceholderASort
+  \fi
+  \vx@Addit\varindexSpaceTexttrue\varindexSpaceSorttrue}
+
+\def\varindexAddTildeB{%
+  \ifvarindexUsePlaceholderB
+    \ifvx@tildeLead
+      \ifvarindexLeadingPlaceholderB
+        \vx@AddingTildeB
+      \fi
+    \else
+      \vx@AddingTildeB
+    \fi
+  \fi}
+\def\vx@AddingTildeB{%
+  \ifvarindexPreviousBText
+    \let\vx@adda\vx@tildeBText
+  \else
+    \let\vx@adda\varindexPlaceholderBText
+  \fi
+  \ifvarindexPreviousBSort
+    \let\vx@addb\vx@tildeBSort
+  \else
+    \let\vx@addb\varindexPlaceholderBSort
+  \fi
+  \vx@Addit\varindexSpaceTexttrue\varindexSpaceSorttrue}
+
+\def\varindexNextSpace{\varindexSpaceTexttrue\varindexSpaceSorttrue}
+\def\varindexNoNextSpace{\varindexSpaceTextfalse\varindexSpaceSortfalse}
+
+\long\def\varindexTokensOut#1#2{\def\vx@adda{#1}\def\vx@addb{#2}\vx@Addit{}{}}
+
+\def\varindexTokensOutExpand#1#2{\let\vx@adda#1\let\vx@addb#2\vx@Addit{}{}}
+
+\def\vx@Addit#1#2{%
+  \ifx\vx@adda\toolboxEmpty\else
+    \vx@tildeLeadfalse
+    \ifvarindexSpaceText
+      \varindexSpaceTextfalse
+      \ifvx@commaTextLead
+        \toolboxAppend\vx@textlistBefore\toolboxSpace
+        \let\vx@textlist\vx@adda
+      \else
+        \toolboxAppend\vx@textlist{\toolboxSpace\vx@adda}%
+      \fi
+    \else
+      \toolboxAppend\vx@textlist\vx@adda
+    \fi
+    \vx@commaTextLeadfalse
+    #1%
+  \fi
+  \ifvarindexIndexMode
+    \ifx\vx@addb\toolboxEmpty\else
+      \ifvarindexSpaceSort
+        \varindexSpaceSortfalse
+        \ifvx@commaSortLead
+          \toolboxAppend\vx@sortlistBefore\toolboxSpace
+          \let\vx@sortlist\vx@addb
+        \else
+          \toolboxAppend\vx@sortlist{\toolboxSpace\vx@addb}%
+        \fi
+      \else
+        \toolboxAppend\vx@sortlist\vx@addb
+      \fi
+      \vx@commaSortLeadfalse
+      #2%
+    \fi
+  \fi}
+
+\def\varindexAddExclam{%
+  \ifvarindexIndexMode
+    \vx@Flush
+    \toolboxAppend\vx@outputlist\varindexOutExclam
+  \else
+    \errmessage{\string\varindex: %
+      Subitem can only be used for index, not for running text}%
+  \fi
+  \varindexFollowsExclam
+}
+
+\expandafter
+\def\expandafter\vx@ErrorFormat\expandafter#\expandafter 1\vx@endparse
+  {\errmessage{\string\varindex: Error in format `#1'}}
+
+\def\vx@ErrorNumber#1#2{\errmessage{\string\varindex: %
+  Entry `#2' does not exist (only #1 entries)}}
+
+\def\vx@Write{%
+  \vx@Flush
+  \ifvarindexIndexMode
+    \toolboxAppend\vx@outputlist\varindexAppend
+    \vx@MakeHarmless\vx@outputlist
+    \expandafter
+    \varindexIndex\expandafter{\vx@outputlist}%
+  \else
+    \expandafter
+    \varindexStyle\expandafter{\vx@outputlist}%
+  \fi}
+
+\def\vx@Flush{%
+  \vx@tildeLeadtrue
+  \vx@commaTextLeadtrue
+  \vx@commaSortLeadtrue
+  \let\vx@tildeAText\vx@textlist
+  \let\vx@tildeBText\vx@textlist
+  \ifvarindexIndexMode
+    \let\vx@tildeASort\vx@sortlist
+    \let\vx@tildeBSort\vx@sortlist
+    \toolboxDef\vx@textlist{\vx@textlistBefore\vx@textlist}%
+    \toolboxDef\vx@sortlist{\vx@sortlistBefore\vx@sortlist}%
+    \ifx\vx@textlist\vx@sortlist
+      \toolboxAppend\vx@outputlist\vx@textlist
+    \else
+      \toolboxAppend\vx@outputlist{\vx@sortlist\vx@otherat\vx@textlist}%
+    \fi
+    \let\vx@sortlistBefore\toolboxEmpty
+    \let\vx@sortlist\toolboxEmpty
+  \else
+    \toolboxAppend\vx@outputlist{\vx@textlistBefore\vx@textlist}%
+  \fi
+  \let\vx@textlistBefore\toolboxEmpty
+  \let\vx@textlist\toolboxEmpty}
+
+\def\vx@TextEntry#1{%
+  \vx@SplitAtSort{#1}\vx@textEntryA\vx@textEntryB
+  \expandafter\vx@SplitAtPlain\expandafter{\vx@textEntryA}%
+    \vx@textEntryA\vx@textEntryC
+  \vx@LetEliminated{varindexEntry}\vx@textEntryA
+  \ifx\vx@textEntryB\undefined
+    \vx@LetEliminated{varindexSort}\vx@textEntryA
+    \ifx\vx@textEntryC\undefined
+      \vx@LetEliminated{varindexPlain}\vx@textEntryA
+    \else
+      \vx@LetEliminated{varindexPlain}\vx@textEntryC
+    \fi
+  \else
+    \ifx\vx@textEntryC\undefined
+      \expandafter\vx@SplitAtPlain\expandafter{\vx@textEntryB}%
+        \vx@textEntryB\vx@textEntryC
+    \fi
+    \vx@LetEliminated{varindexSort}\vx@textEntryB
+    \ifx\vx@textEntryC\undefined
+      \vx@LetEliminated{varindexPlain}\vx@textEntryA
+    \else
+      \vx@LetEliminated{varindexPlain}\vx@textEntryC
+    \fi
+  \fi
+}
+\def\vx@LetEliminated#1#2{%
+  \let\vx@tmp#2%
+  \ifvarindexEliminateInnerBrace
+    \toolboxDropBrace\vx@tmp
+  \fi
+  \toolboxWithNr{\the\varindexCount}\let{#1}\vx@tmp}
+
+\def\varindexMakeVarSplit#1#2#3{\varindexedef#1{#2}\expandafter
+  \toolboxMakeSplit\expandafter{#1}{#3}}
+\def\varindexMakeSplitExpand#1#2{\varindexMakeVarSplit\vx@tmp{#1}{#2}}
+
+\def\varindexSetWordString#1{\def\vx@word{#1}%
+  \toolboxMakeSplit{#1}{vx@SplitAtWord}}
+\def\varindexSetSortString#1{%
+  \toolboxMakeSplit{#1}{vx@SplitAtSort}}
+\def\varindexSetPlainString#1{%
+  \toolboxMakeSplit{#1}{vx@SplitAtPlain}}
+
+\def\vx@tmp#1{%
+  \expandafter
+  \def\expandafter\vx@adda\expandafter##\expandafter 1\expandafter{%
+    \expandafter
+    \varindexMakeVarSplit\csname varindex#1String\endcsname
+    {##1}{varindexSplitAt#1}}%
+  \expandafter
+  \let\csname varindexSet#1String\endcsname\vx@adda}
+\vx@tmp{Index}
+\vx@tmp{Output}
+\vx@tmp{TildeA}
+\vx@tmp{TildeB}
+\vx@tmp{Space}
+\vx@tmp{SpaceTok}
+\vx@tmp{Omit}
+\vx@tmp{Comma}
+\vx@tmp{Dash}
+\vx@tmp{Exclam}
+
+\def\varindexSetStringForNr#1#2{%
+  \edef\vx@adda{#1}%
+  \expandafter
+    \vx@AddToHandleNrs\csname varindexSplitAtNr\vx@adda\endcsname
+  \expandafter
+    \varindexMakeVarSplit\csname varindexNr\vx@adda String\endcsname
+      {#2}{varindexSplitAtNr\vx@adda}}
+
+\def\vx@AddToHandleNrs#1{%
+  \ifx#1\relax
+    \expandafter
+      \varindexNewFormat\expandafter#1\expandafter{\expandafter
+        \varindexAddNumber\expandafter{\vx@adda}}%
+  \fi}
+
+\def\varindexedef#1#2{%
+  \let\vx@tildemerk~%
+  \let~\vx@nicetilde
+  \edef#1{#2}%
+  \let~\vx@tildemerk}
+
+\def\varindexDoConvert{\let\vx@MakeHarmless\toolboxMakeHarmless}
+
+\def\varindexNoConvert{\def\vx@MakeHarmless##1{}}
+
+\def\vx@tmp{\catcode`\~=13\relax}
+\catcode`\~=11\relax\def\vx@nicetilde{~}\vx@tmp
+
+\def\vx@MakeSpaceOther{\catcode`\ =13\relax}
+\def\vx@MakeSpaceSpace{\catcode`\ =10\relax}
+\vx@MakeSpaceOther%<- This % is important
+\let\vx@spaceothertok= %<- This ` %' is important
+\vx@MakeSpaceSpace
+
+\def\varindexArgumentSpace#1{\def\vx@otherat{#1}}
+\ifx\makeatother\undefined\catcode`\@=12\relax\else\makeatother\fi
+\varindexArgumentSpace{@}
+
+\let\varindexArgumentSpace\varindexSkipDefault
+
+\toolboxIf\undefined\def\varindexIndex{\index}
+
+\varindexDoConvert
+
+\toolboxIf\undefined\def\varindexOutExclam{!}
+\toolboxIf\undefined\let\varindexFollowsExclam\varindexNoNextSpace
+\toolboxIf\undefined\def\varindexOutTextComma{,}
+\toolboxIf\undefined\def\varindexOutSortComma{,}
+\toolboxIf\undefined\let\varindexFollowsComma\varindexNextSpace
+\toolboxIf\undefined\let\varindexPreceedsComma\varindexNoNextSpace
+\toolboxIf\undefined\def\varindexOutTextSpace{ }
+\toolboxIf\undefined\def\varindexOutSortSpace{ }
+\toolboxIf\undefined\let\varindexFollowsSpace\toolboxEmpty
+\toolboxIf\undefined\let\varindexPreceedsSpace\varindexNoNextSpace
+\toolboxIf\undefined\def\varindexOutTextSpTok{\space}
+\toolboxIf\undefined\def\varindexOutSortSpTok{ }
+\toolboxIf\undefined\let\varindexFollowsSpTok\toolboxEmpty
+\toolboxIf\undefined\let\varindexPreceedsSpTok\varindexNoNextSpace
+\toolboxIf\undefined\def\varindexOutTextDash{-}
+\toolboxIf\undefined\def\varindexOutSortDash{-}
+\toolboxIf\undefined\let\varindexOutSortDashBeg\toolboxEmpty
+\toolboxIf\undefined\let\varindexFollowsDash\toolboxEmpty
+\toolboxIf\undefined\let\varindexPreceedsDash\varindexNoNextSpace
+\toolboxIf\undefined\let\varindexOutTextOmit\toolboxEmpty
+\toolboxIf\undefined\let\varindexOutSortOmit\toolboxEmpty
+\toolboxIf\undefined\let\varindexFollowsOmit\toolboxEmpty
+\toolboxIf\undefined\let\varindexPreceedsOmit\varindexNoNextSpace
+%% It is important that the following is after all \toolboxIf\undefined...
+\varindexAddOmit% Execute the fake macro and redefine \varindexAddOmit
+
+\toolboxMakeSplit{ }{varindexSplitSpace}
+
+\varindexSetWordString{ }
+\varindexSetSortString{@}
+\varindexSetPlainString{!}
+
+\varindexSetIndexString{ }
+\varindexSetOutputString{*}
+
+\varindexSetTildeAString{~}
+\varindexSetTildeBString{=}
+\varindexSetSpaceString{_}
+\varindexSetSpaceTokString{s}
+\varindexSetOmitString{.}
+\varindexSetCommaString{,}
+\varindexSetDashString{-}
+\varindexSetExclamString{!}
+\varindexSetStringForNr{10}{0}
+\varindexSetStringForNr 9{9}
+\varindexSetStringForNr 8{8}
+\varindexSetStringForNr 7{7}
+\varindexSetStringForNr 6{6}
+\varindexSetStringForNr 5{5}
+\varindexSetStringForNr 4{4}
+\varindexSetStringForNr 3{3}
+\varindexSetStringForNr 2{2}
+\varindexSetStringForNr 1{1}
+
+\ifx\makeatletter\undefined\catcode`\@=11\relax\else\makeatletter\fi
+
+\endinput
+%%
+%% End of file `varindex.sty'.
-- 
cgit v1.2.3

