summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-03 00:43:56 +0000
committerKarl Berry <karl@freefriends.org>2009-09-03 00:43:56 +0000
commit382a6396f8c5958758712db789f58b00946d5667 (patch)
tree7f64e343baff9c14ad336546bf7dd246f3b32377 /Master/texmf-dist/source/latex
parent87b7696d3c95e7c58da2f1ed33f5ae85a777a5a0 (diff)
boolexpr update (2sep09)
git-svn-id: svn://tug.org/texlive/trunk@15010 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r--Master/texmf-dist/source/latex/boolexpr/boolexpr.dtx411
-rw-r--r--Master/texmf-dist/source/latex/boolexpr/boolexpr.ins2
2 files changed, 236 insertions, 177 deletions
diff --git a/Master/texmf-dist/source/latex/boolexpr/boolexpr.dtx b/Master/texmf-dist/source/latex/boolexpr/boolexpr.dtx
index fb4f03f7095..60c967e3666 100644
--- a/Master/texmf-dist/source/latex/boolexpr/boolexpr.dtx
+++ b/Master/texmf-dist/source/latex/boolexpr/boolexpr.dtx
@@ -1,5 +1,5 @@
% \iffalse meta-comment
-% boolexpr : purely expandable boolean expressions and switch (eTeX)
+% boolexpr : purely expandable boolean expressions and switch (eTeX) [v3.0 2009/09/03]
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
@@ -9,7 +9,7 @@
%
% Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
%
-% This work consists of the main source file keycommand.dtx
+% This work consists of the main source file boolexpr.dtx
% and the derived files
% boolexpr.sty, boolexpr.pdf, boolexpr.ins,
%
@@ -38,7 +38,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: boolexpr 2009/08/12 v2.1 provides purely expandable boolean expressions and switch (eTeX)}
+\Msg{* Package: boolexpr 2009/09/03 v3.0 provides purely expandable boolean expressions and switch (eTeX)}
\Msg{************************************************************************}
\keepsilent
@@ -93,20 +93,22 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
\fi
%</ignore>
%<*driver>
+\listfiles
\edef\thisfile{\jobname}
\def\thisinfo{Purely expandable boolean expressions and switch (\eTeX).}
+\def\thisversion{v3.0}
+\def\thisdate{2009/09/03}
\let\loadclass\LoadClass
\def\LoadClass#1{\loadclass[abstracton]{scrartcl}\let\scrmaketitle\maketitle\AtEndOfClass{\let\maketitle\scrmaketitle}}
\documentclass[a4paper,oneside]{ltxdoc}
-\usepackage{tracing}
\usepackage[latin9]{inputenc}
\usepackage[american]{babel}
-\usepackage{etex,holtxdoc,etoolbox,geometry,tocloft,fancyhdr,color,bbding,embedfile,enumitem,framed,txfonts,relsize}\CodelineNumbered
-\usepackage{fancyvrb}
-\IfFileExists{boolexpr.sty}
- {\RequirePackage{boolexpr}}
+\usepackage{etex,holtxdoc,etoolbox,xspace,geometry,tocloft,fancyhdr,color,bbding,makecell,enumitem,framed,txfonts,relsize}\CodelineNumbered
+\usepackage{fancyvrb,ifpdf}
+\IfFileExists{\thisfile.sty}
+ {\RequirePackage{\thisfile}}
\relax
-\embedfile{\thisfile.dtx}
+\ifpdf\usepackage{embedfile}\embedfile{\thisfile.dtx}\fi
\geometry{top=2cm,headheight=1cm,headsep=.3cm,bottom=1.4cm,footskip=.5cm,left=4cm,right=2cm}
\hypersetup{%
pdftitle={The boolexpr package},
@@ -122,7 +124,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%</driver>
% \fi
%
-% \CheckSum{257}
+% \CheckSum{307}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -145,7 +147,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \DoNotIndex{\NeedsTeXFormat,\OnlyDescription,\RecordChanges,\usepackage}
% \DoNotIndex{\ProvidesClass,\ProvidesPackage,\ProvidesFile,\RequirePackage}
% \DoNotIndex{\filename,\fileversion,\filedate,\let}
-% \DoNotIndex{\@listctr,\@nameuse,\csname,\else,\endcsname,\expandafter}
+% \DoNotIndex{\@listctr,\@nameuse,\csname,\else,\endcsname,\expandafter,\@ehd,\@nil,\bex,\case,\endcase}
% \DoNotIndex{\gdef,\global,\if,\item,\newcommand,\nobibliography}
% \DoNotIndex{\par,\providecommand,\relax,\renewcommand,\renewenvironment}
% \DoNotIndex{\stepcounter,\usecounter,\nocite,\fi}
@@ -172,7 +174,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \newcommand\cmdref[1]{\hyperref[#1]{\underline{\reflinkcolor\CS{#1}}}}
% \newcommand\cmdlabel[1]{\label{#1}\hyperdef{cmdlabel}{#1}{}}
% \definecolor{dg}{rgb}{0.02,0.37,0.00}
-% \def\ThisPackage{\Xpackage{\thisfile}}\def\thispackage{\xpackage{\thisfile}}
+% \def\ThisPackage{\Xpackage{\thisfile}\xspace}\def\thispackage{\xpackage{\thisfile}\xspace}
% \fancyhf{}\fancyhead[L]{\thispackage\ -- \thisinfo}
% \fancyfoot[L]{\color[gray]{.35}\scriptsize\thispackage\quad\copyright\oldstylenums{2009}\,\lower.3ex\hbox{\NibRight}\,Florent Chervet}
% \fancyfoot[R]{\oldstylenums{\thepage} / \oldstylenums{\pageref{LastPage}}}
@@ -201,26 +203,28 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \newcommand\myfbox[2][3em]{\fbox{\hbox to#1{\hss#2\hss}}}
% \newbox\boxedb@x
% \newcommand\boxedbox[1]{\setbox\boxedb@x\vbox{#1}\fbox{\box\boxedb@x}}
-% \DefineVerbatimEnvironment{VerbEx}{Verbatim}{gobble=1,commandchars=![]}
+% \DefineVerbatimEnvironment{VerbEx}{Verbatim}{gobble=1,commandchars=![],fontfamily=tt,fontseries=tt,fontshape=tt}
% \newcommand\evaluated{\textcolor{blue}}
% \newcommand\notevaluated{\textcolor{black}}
% \newcommand\stripmeaning{\expandafter\strip@prefix\meaning}
+%
% \makeatother
%
-% \title{\mdseries The {\bfseries \ThisPackage}\kern.6em package}
-% \author{Florent Chervet {\small\xemail{florent.chervet@free.fr}}}
-% \date{July 22, 2009}
+% \title{\vskip-2cm\mdseries The {\bfseries \ThisPackage}\kern.6em package}
+% \author{\small\xemail{florent.chervet@free.fr}}
+% \date{\thisdate -- \thisversion}
% \subtitle{\thisinfo}
%
+%
% \maketitle \vskip-2\baselineskip\strut
%
% \makeatletter\begingroup\let\@thefnmark\@empty\let\@makefntext\@firstofone
% \footnotetext{\noindent
% This documentation is produced with the |DocStrip| utility.
% \begin{tabbing}
-% \qquad\=\smex\=To get the documentation, \= run (thrice):\quad\= \texttt{pdflatex boolexpr.dtx} \\
-% \>\>for the index:\>\>\texttt{makeindex -s gind.ist boolexpr.idx} \\
-% \>\smex\>To get the package, \> run:\> \texttt{etex boolexpr.dtx}
+% \qquad\=\smex\=To get the documentation, \= run (thrice):\quad\= \texttt{pdflatex \thisfile.dtx} \\
+% \>\>for the index:\>\>\texttt{makeindex -s gind.ist \thisfile.idx} \\
+% \>\smex\>To get the package, \> run:\> \texttt{etex \thisfile.dtx}
% \end{tabbing}§
% The \xext{dtx} file is embedded into this pdf file thank to \xpackage{embedfile} by H. Oberdiek.}
% \endgroup\makeatother
@@ -229,7 +233,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%
% \begin{abstract}\parindent0pt\noindent\parskip\medskipamount\small\abovedisplayskip=0pt\belowdisplayskip=0pt
% \vskip-\baselineskip
-% \xpackage{boolexpr} provides a purely expandable way to evaluate boolean expressions of the form:
+% \thispackage provides a purely expandable way to evaluate boolean expressions of the form:
%
% \hfil\framebox[.618\linewidth][c]{$\alpha\quad\cs{AND}\quad\beta\quad\cs{OR}\quad\gamma\quad\dots$}\hfil
%
@@ -246,27 +250,30 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% or |\muexpr| -- please refer to the \nameref{examples}) and \meta{test} may be a switch (\cs{iftrue} / \cs{iffalse}
% or a conditional\footnote{\cs{if}, \cs{ifcase}, \cs{ifcat}, \cs{ifcsname}, \cs{ifdefined}, \cs{ifdim}, \cs{ifeof},
% \cs{iffontchar}, \cs{ifhmode}, \cs{ifinner}, \cs{ifmmode}, \cs{ifnum}, \cs{ifodd}, \cs{ifvmode}, \cs{ifvoid}, \cs{ifx}}).
-% \xpackage{boolexpr} abide by the precedence of |\AND| on |\OR|,
+% \thispackage abide by the precedence of |\AND| on |\OR|,
% and the whole expression is evaluated until the result is known (in other words, |\AND| and |\OR| are \textit{shortcut}
% boolean operators).
%
-% \cmdref{boolexpr} will expand to \textbf{0} if the expression is \textbf{true}, making it proper to work with |\ifcase|.
+% \cmdref{boolexpr} will expand to \textbf{0} if the expression is \textbf{true}, making it proper to work with |\ifcase|
+% Furthermore, \thispackage defines a \cmdref{switch} syntax which remains purely expandable.
%
-% Furthermore, \xpackage{boolexpr} defines a \cmdref{switch} syntax which remains purely expandable.
+% \textbf{Be aware that \cs{boolexpr} (a little like \cs{numexpr}) works only if its argument is purely expandable};
+% the same for \cs{switch}. If you wish a more general \cs{CASE} syntax refer to this excellent paper:
+% \url{http://www.tug.org/TUGboat/Articles/tb14-1/tb38fine.pdf}.
%
-% The \xpackage{boolexpr} package is designed to work with an \eTeX{} distribution of \LaTeX{}:
+% The \thispackage package is designed to work with an \eTeX{} distribution of \LaTeX{}:
% it is based on the \eTeX{} |\numexpr| primitive and requires no other package.
%
-% \end{abstract}\vskip-\baselineskip
+% \end{abstract}\vskip-.5\baselineskip
%
% \cftbeforesecskip=5pt plus2pt minus4pt
-% \bigskip\setcounter{tocdepth}{2}
+% \smallskip\setcounter{tocdepth}{2}
% {\smaller\tableofcontents}
%
% \def\B#1{\texttt{[}\meta{#1}\texttt{]}}
%
-%
-% \section{Introduction -- Using \xpackage{boolexpr} : \cs{boolexpr} and \cs{switch}}
+% \catcode95 11% _
+% \section{Introduction -- Using \thispackage : \cs{boolexpr} and \cs{switch}}
%
% \begin{declcs}{boolexpr}\,\M{boolean expression}
% \end{declcs}\cmdlabel{boolexpr}
@@ -484,8 +491,8 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \\ \hline
% \end{tabular}
%
-% \ifboolexprLoaded Results in green were evaluated by \xpackage{boolexpr.sty} at compilation time.
-% \else Results in green were not evaluated at compilation time: \xpackage{boolexpr} was not found.
+% \ifboolexprLoaded Results in \textcolor{green}{green} were evaluated by \thispackage at compilation time.
+% \else Results in \textcolor{green}{green} were not evaluated at compilation time: \thispackage was not found.
% \fi
%
% \clearpage
@@ -498,12 +505,12 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \CS{endswitch}
% \end{declcs}\cmdlabel{switch}
%
-% \xpackage{boolexpr} defines a syntax for \cs{switch} conditionals which remains purely expandable:
+% \thispackage defines a syntax for \cs{switch} conditionals which remains purely expandable:
% \iffalse
% \begin{VerbEx}
% \switch
% !textbf[\case]{ !meta[bool expr] } ...
-% !textbf[\case]{ !meta[beel expr] } ...
+% !textbf[\case]{ !meta[bool expr] } ...
% !textbf[\case]{ !meta[bool expr] } ...
% !textbf[\otherwise] ...
% \endswitch
@@ -513,32 +520,41 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \textbf{Each part of the switch is optional.} That means:
% \begin{center}
% \begin{tabular}{m{.4\textwidth}m{.4\textwidth}}
-% \begin{VerbEx}
+% \begin{VerbEx}[frame=single]
% \switch
% !textbf[\case]{ !meta[bool expr] } ...
% !textbf[\case]{ !meta[beel expr] } ...
% !textbf[\case]{ !meta[bool expr] } ...
+% !textbf[\otherwise] ...
% \endswitch
% \end{VerbEx}
-% &
-% \begin{VerbEx}
+% &
+% \begin{VerbEx}[frame=single]
+% \switch
+% !textbf[\case]{ !meta[bool expr] } ...
+% !textbf[\case]{ !meta[beel expr] } ...
+% !textbf[\case]{ !meta[bool expr] } ...
+% \endswitch
+% \end{VerbEx}
+% \\
+% \begin{VerbEx}[frame=single]
% \switch
% !textbf[\otherwise] ...
% \endswitch
% \end{VerbEx}
-% \\
-% \begin{VerbEx}
+% &
+% \begin{VerbEx}[frame=single]
% \switch
% \endswitch
% \end{VerbEx}
-% & are allowed by \xpackage{boolexpr}.
-% \end{tabular}
+% \end{tabular}\\
+% are allowed by \thispackage.
% \end{center}
-%
+%
%
%
% \subsection*{\CSbf{switch} examples}\label{switchexamples}\addcontentsline{toc}{subsection}{switch examples}
-%
+%
% The part of the expression that is evaluated \textcolor{blue}{is in blue} (the remainder is not evaluated).
%
% \begin{tabular}{m{9.5cm}>{\color{dg}\smex\tt}m{5.6cm}}\hline
@@ -581,35 +597,81 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \fi
% result:\par\stripmeaning\result
% \\ \hline
-% \begin{VerbEx}
-% \def\result#1{\textbf{%
-% !evaluated[\switch]
-% !evaluated[\case{\pdfstrcmp{#1}{one}}one]%
-% !evaluated[\case{\pdfstrcmp{#1}{two}}two]%
-% !evaluated[\otherwise something else]%
-% !evaluated[\endswitch]}}
+% \begin{VerbEx}[commandchars=!()]
+% \newcounter{myCounter} \setcounter{myCounter}{2}
+% \edef\result{%
+% !evaluated(\switch)[\value{myCounter}=]
+% !evaluated(\case{1}one)%
+% | ----------------------------> |
+% !evaluated(\case{2}two)% <=> \case{value{myCounter}=2}
+% \case{3}three%
+% \case{2}vartwo%(never found)%
+% \otherwise something else%
+% !evaluated(\endswitch)}
%
-% \protected@edef\result{\result{12}}
% \end{VerbEx}
% &
% \ifboolexprLoaded
-% \def\result#1{\textbf{%
-% \switch
-% \case{\pdfstrcmp{#1}{one}}one%
-% \case{\pdfstrcmp{#1}{two}}two%
-% \otherwise something else%
-% \endswitch}}
-% \makeatletter\protected@edef\result{\result{12}}\makeatother
+% \newcounter{myCounter} \setcounter{myCounter}{2}
+% \edef\result{%
+% \switch[\value{myCounter}=]
+% \case{2}two%
+% \case{3}three%
+% \case{2}vartwo%
+% \otherwise something else%
+% \endswitch}
% \else
-% \makeatletter\protected@edef\result{\textbf{something else}}\makeatother
+% \edef\result{two}
% \fi
% result:\stripmeaning\result
% \\ \hline
-%
+% \begin{VerbEx}[commandchars=!()]
+% !evaluated(switch)[\value{myCounter}]
+% !evaluated(\case{=1})It's $1$%
+% !evaluated(\case{=-1})It's $-1$%
+% |-| -------------------------> |-|
+% !evaluated(\case{>=0})It's $>=0$% <=> \case{\value{myCounter}>=0}
+% \otherwise something else%
+% !evaluated(\endswitch)
+% \end{VerbEx}
+% &
+% \ifboolexprLoaded \loggingall
+% \vspace*{2cm}%
+% \switch[\value{myCounter}]
+% \case{=1}It's $1$%
+% \case{=-1}It's $-1$%
+% \case{>=0}It's $>=0$%
+% \otherwise something else%
+% \endswitch
+% \else It's $>=0$%
+% \fi
+% \\\hline
+% \begin{VerbEx}[commandchars=!()]
+% !evaluated(switch)[\pdfstrcmp{DuMmY}]
+% !evaluated(\case{{First}})It's "First"%
+% |-| -------------------------> |-|
+% !evaluated(\case{{DuMmY})It's DuMmY%
+% \otherwise something else%
+% !evaluated(\endswitch)
+% \end{VerbEx}
+% &
+% \ifboolexprLoaded
+% \ifdefined\pdfstrcmp
+% \vspace*{2cm}%
+% \switch[\pdfstrcmp{DuMmY}]
+% \case{{First}}It's "First"%
+% \case{{DuMmY}}It's "DuMmY"%
+% \otherwise something else%
+% \endswitch
+% \else It's It's "DuMmY"%
+% \fi
+% \else It's "DuMmY"%
+% \fi
+% \\\hline
% \end{tabular}
%
-% \ifboolexprLoaded Results in green were evaluated by \xpackage{boolexpr.sty} at compilation time.
-% \else Results in green were not evaluated at compilation time: \xpackage{boolexpr} was not found.
+% \ifboolexprLoaded Results in \textcolor{green}{green} were evaluated by \xpackage{boolexpr.sty} at compilation time.
+% \else Results in \textcolor{green}{green} were not evaluated at compilation time: \thispackage was not found.
% \fi
%
% \StopEventually{
@@ -717,7 +779,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \begin{macrocode}
%<*package>
\ProvidesPackage{boolexpr}
- [2009/08/12 v2.1 Purely expandable boolean expressions and switch (eTeX)]
+ [2009/09/03 v3.0 Purely expandable boolean expressions and switch (eTeX)]
% \end{macrocode}
% \iffalse
%<package>
@@ -737,19 +799,23 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
}%
\catcode#1 #2\relax
}
-\TMP@EnsureCode{42}{4}% :
+\TMP@EnsureCode{95}{11}% _
+\TMP@EnsureCode{36}{12}% $
+\TMP@EnsureCode{60}{12}% <
+\TMP@EnsureCode{61}{12}% =
+\TMP@EnsureCode{62}{12}% >
% \end{macrocode}
% \iffalse
%<package>
% \fi
%
-% \subsection{Helper macros}
+% \subsection{Tree helper macros}
%
% While reading the \texttt{log} file it is preferable to read |\@firstoftwo|/|\@secondoftwo|
% when the algorithm is making a choice (|\ifblank|) and |\bex@truepart|/|bex@falsepart|
% when the algorithm has just determined the result of an atomic expression.
% \iffalse
-%<package>% Five helper macros
+%<package>% Three helper macros
% \fi
% \begin{macrocode}
\let\bex@truepart\@firstoftwo
@@ -759,29 +825,14 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>
% \fi
%
-% \begin{macrocode}
-\def\bex@afterelse#1\else#2\fi{\fi#1}
-% \end{macrocode}
-% \iffalse
-%<package>
-% \fi
%
-% \begin{macro}{\bex@ifblank}
+% \begin{macro}{\bex__ifnotblank}
% The following macro is purely expandable and its code is most probably due to D. Arseneau (\xpackage{url.sty})
% \begin{macrocode}
-\begingroup\catcode`\|=3
-\long\gdef\bex@ifblank#1{\bex@ifbl@nk#1||\@secondoftwo\@firstoftwo:}
-\long\gdef\bex@ifbl@nk#1#2|#3#4#5:{#4}
-\endgroup
+\long\def\bex__ifnotblank#1#2$#3#4#5$${#4}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\bex@ifblankdef}
-% It's just the same but expand once the control sequence given as an argument.
-% \begin{macrocode}
-\long\def\bex@ifblankdef#1{\expandafter\bex@ifblank\expandafter{#1}}
-% \end{macrocode}
-% \end{macro}
% \iffalse
%<package>
% \fi
@@ -802,23 +853,16 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>% \bex@rel tests each atomic expression: choose which evaluation macro to use first
% \fi
% \begin{macrocode}
-\def\bex@rel#1{%
- \bex@test@eval#1:
- {\bex@eval{#1}}
- {\bex@test@neq#1<>:
- {\bex@test@infeq#1<=:
- {\bex@test@inf#1<:
- {\bex@test@supeq#1>=:
- {\bex@test@sup#1>:
- {\bex@test@eq#1=:
+\long\def\bex@rel#1{%
+ \bex@test_eval#1${\bex@eval{#1}}
+ {\bex@test_neq#1<>$${\bex@neq #1$}
+ {\bex@test_infeq#1<=$${\bex@infeq #1$}
+ {\bex@test_inf#1<$${\bex@inf #1$}
+ {\bex@test_supeq#1>=$${\bex@supeq #1$}
+ {\bex@test_sup#1>$${\bex@sup #1$}
+ {\bex@test_eq#1=$${\bex@eq #1$}
{\@latex@error{Unknown relation found while scanning
- \noexpand\boolexpr!}\@ehd}
- {\bex@eq#1:}}
- {\bex@sup#1:}}
- {\bex@supeq#1:}}
- {\bex@inf#1:}}
- {\bex@infeq#1:}}
- {\bex@neq#1:}}}
+ \noexpand\boolexpr!}\@ehd}$$}$$}$$}$$}$$}$$}}
% \end{macrocode}
% \end{macro}
% \iffalse
@@ -831,41 +875,43 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>% Tests macros to determine the type of each atomic expression
% \fi
% \begin{macrocode}
-\def\bex@test@neq#1<>#2:{\bex@ifblank{#2}}
-\def\bex@test@eq#1=#2:{\bex@ifblank{#2}}
-\def\bex@test@infeq#1<=#2:{\bex@ifblank{#2}}
-\def\bex@test@inf#1<#2:{\bex@ifblank{#2}}
-\def\bex@test@supeq#1>=#2:{\bex@ifblank{#2}}
-\def\bex@test@sup#1>#2:{\bex@ifblank{#2}}
-\def\bex@test@eval#1#2:{%
+\def\bex@test_neq#1<>#2${\bex__ifnotblank#2$}
+\def\bex@test_eq#1=#2${\bex__ifnotblank #2$}
+\def\bex@test_infeq#1<=#2${\bex__ifnotblank #2$}
+\def\bex@test_inf#1<#2${\bex__ifnotblank #2$}
+\def\bex@test_supeq#1>=#2${\bex__ifnotblank #2$}
+\def\bex@test_sup#1>#2${\bex__ifnotblank #2$}
+\long\def\bex@test_eval#1#2${%
\ifcat\noexpand#1\relax% #1 is a control sequence
- \bex@afterelse\bex@test@Eval{#1}
+ \bex@test_Eval{#1}
\else \expandafter\@secondoftwo
\fi}
-\def\bex@test@Eval#1{\csname @%
+\long\def\bex@test_Eval#1#2\fi{\fi\csname @%
\ifx#1\the second%
\else\ifx#1\numexpr second%
\else\ifx #1\number second%
\else\ifx #1\dimexpr second%
\else\ifx #1\glueexpr second%
\else\ifx #1\muexpr second%
+ \else\ifx #1\value second%
\else first%
- \fi\fi\fi\fi\fi\fi oftwo\endcsname}
+ \fi\fi\fi\fi\fi\fi\fi oftwo\endcsname}
% \end{macrocode}
% \end{macro}
% \iffalse
%<package>
% \fi
%
+%
% \begin{macro}{Evaluation macros}
% They evaluate each \textit{atomic expression} according to its type:
% \iffalse
%<package>% Evaluation macro that evaluates an atomic expression depending on its type:
% \fi
% \begin{macrocode}
-\def\bex@true@or@false#1{\csname bex@%
+\long\def\bex@true_or_false#1{\csname bex@%
\ifnum\numexpr#1 true\else false\fi part\endcsname}
-\def\bex@false@or@true#1{\csname bex@%
+\def\bex@false_or_true#1{\csname bex@%
\ifnum\numexpr#1 false\else true\fi part\endcsname}
% \end{macrocode}
%
@@ -873,13 +919,13 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>
% \fi
% \begin{macrocode}
-\def\bex@eq#1=#2:{\bex@true@or@false{#1-(#2)=0}}
-\def\bex@neq#1<>#2:{\bex@false@or@true{#1-(#2)=0}}
-\def\bex@infeq#1<=#2:{\bex@false@or@true{#1-(#2)>0}}
-\def\bex@inf#1<#2:{\bex@true@or@false{#1-(#2)<0}}
-\def\bex@supeq#1>=#2:{\bex@false@or@true{#1-(#2)<0}}
-\def\bex@sup#1>#2:{\bex@true@or@false{#1-(#2)>0}}
-\def\bex@eval#1{\bex@true@or@false{#1=0}}
+\def\bex@eq#1=#2${\bex@true_or_false{#1-(#2)=0}}
+\def\bex@neq#1<>#2${\bex@false_or_true{#1-(#2)=0}}
+\def\bex@infeq#1<=#2${\bex@false_or_true{#1-(#2)>0}}
+\def\bex@inf#1<#2${\bex@true_or_false{#1-(#2)<0}}
+\def\bex@supeq#1>=#2${\bex@false_or_true{#1-(#2)<0}}
+\def\bex@sup#1>#2${\bex@true_or_false{#1-(#2)>0}}
+\long\def\bex@eval#1{\bex@true_or_false{#1=0}}
% \end{macrocode}
% \end{macro}
% \iffalse
@@ -894,23 +940,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>% \bex@OR splits the string to evaluate into two parts: before the first \OR and after
% \fi
% \begin{macrocode}
-\def\bex@OR#1\OR#2:{%
- \bex@ifblank{#2}
- {\bex@AND{}#1\AND:}
- {\expandafter\bex@AND\expandafter{\bex@removeOR#2:}#1\AND:}}
-% \end{macrocode}
-% \end{macro}
-% \iffalse
-%<package>
-% \fi
-%
-% \begin{macro}{bex@removeOR}
-% Just remove the extra |\OR:| inserted into the argument of |\bex@OR|:
-% \iffalse
-%<package>% \remove@OR removes the extra \OR: inserted into the argument of \bex@OR
-% \fi
-% \begin{macrocode}
-\def\bex@removeOR#1\OR:{#1}
+\long\def\bex@OR#1\OR#2${\bex@AND{#2}#1\AND$}
% \end{macrocode}
% \end{macro}
% \iffalse
@@ -923,12 +953,10 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>% \bex@AND splits the string to evaluate into two parts: before the first \AND and after:
% \fi
% \begin{macrocode}
-\def\bex@AND#1#2\AND#3:{%
+\long\def\bex@AND#1#2\AND#3${%
\bex@rel{#2}
- {\bex@ifblank{#3}
- {0}
- {\bex@ANDAND{#1}#3:}}
- {\bex@ifblank{#1}{+1}{\bex@OR#1 \OR:}}}
+ {\bex__ifnotblank #3$${\bex@ANDAND{#1}#3$}{+0}$$}
+ {\bex__ifnotblank #1$${\bex@OR#1$}{+1}$$}}
% \end{macrocode}
% \end{macro}
% \iffalse
@@ -942,10 +970,10 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>% \bex@ANDAND evaluate successive atomic expressions related by \AND:
% \fi
% \begin{macrocode}
-\def\bex@ANDAND#1#2\AND#3:{%
+\long\def\bex@ANDAND#1#2\AND#3${%
\bex@rel{#2}
- {\bex@ifblank{#3}{+0}{\bex@ANDAND{#1}#3:}}
- {\bex@ifblank{#1}{+1}{\bex@OR#1 \OR:}}}
+ {\bex__ifnotblank #3$${\bex@ANDAND{#1}#3$}{+0}$$}
+ {\bex__ifnotblank #1$${\bex@OR#1$}{+1}$$}}
% \end{macrocode}
% \end{macro}
% \iffalse
@@ -958,29 +986,20 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%<package>% \boolexpr: the entry point for evaluating boolean expressions
% \fi
% \begin{macrocode}
-\newcommand\boolexpr[1]{\bex@ifblank{#1}{1}{\numexpr\bex@OR#1 \OR:+0}}
+\newcommand\boolexpr[1]{\bex__ifnotblank #1$${\numexpr\bex@OR#1 \OR$}{+1}$$}
% \end{macrocode}
% \end{macro}
% \iffalse
%<package>
% \fi
%
-% \begin{macro}{\@first@or@second}
-%
-% \begin{macrocode}
-\newcommand\bex@first@or@second[1]{%
- \csname bex@\ifnum\boolexpr{#1}=0 true\else false\fi part\endcsname}
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\ifboolexpr}
% |\ifboolexpr| is the \LaTeX{} form of |\boolexpr| tests:
% \iffalse
%<package>% \ifboolexpr: the LaTeX form of \boolexpr tests
% \fi
% \begin{macrocode}
-\newcommand\ifboolexpr{}
-\let\ifboolexpr\bex@first@or@second
+\newcommand\ifboolexpr[1]{\bex@true_or_false{\boolexpr{#1}=0}}
% \end{macrocode}
% \end{macro}
% \iffalse
@@ -990,51 +1009,90 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
% \begin{macro}{\switch}
% \cs{switch} is not long to implement... see:
% \begin{macrocode}
-\def\switch#1\endswitch{\bex@ifblank{#1}{}%
- {\bex@switch@otherwise#1\otherwise\endswitch}}
+\long\def \switch#1\endswitch {\bex__ifnotblank#1$${\bex@switch_opt#1 \endswitch}{}$$}
+\long\def \bex@switch_opt#1#2\endswitch {\bex_ifsinglechar [{#1}%
+ {\bex@switch_opti#1#2\endswitch}{\bex@switch_opti[]#1#2\endswitch}}%]
+\def \bex@switch_opti[#1]#2\endswitch {\bex@switch_otherwise[{#1}]#2\otherwise\endswitch}
-\def\bex@switch@otherwise#1\otherwise#2\endswitch{%
- \bex@switch@case#1\case\endswitch
- {\bex@ifblank{#2}{}{\bex@otherwise#2\endswitch}}
+\def\bex@switch_otherwise[#1]#2\otherwise#3\endswitch{%
+ \bex@switch_case[{#1}]#2\case\endswitch
+ {\bex__ifnotblank#3$${\bex@otherwise#3\endswitch}{}$$}
\endswitch}
-
-\def\bex@switch@case#1\case#2\endswitch{%
- \bex@ifblank{#1}
- {\bex@ifblank{#2}{\@firstoftwo}{\bex@switch@case#2\endswitch}}
- {\case#1\endcase
- {\bex@ifblank{#2}{\@firstoftwo}{\bex@switch@case#2\endswitch}}%
- }}
-\def\case#1#2\endcase{%
- \ifboolexpr{#1}{\bex@after@endswitch{#2}}}
+\def\bex@switch_case[#1]#2\case#3\endswitch{\bex__ifnotblank#2$$%
+ {\bex@case[{#1}]#2\endcase%
+ {\bex__ifnotblank#3$${\bex@switch_case[{#1}]#3\endswitch}\@firstoftwo$$}}%
+ {\bex__ifnotblank#3$${\bex@switch_case[{#1}]#3\endswitch}\@firstoftwo$$}$$}
-\def\bex@after@endswitch#1#2\endswitch{#1}
-\def\bex@otherwise#1\otherwise#2\endswitch{#1}
+\long\def\bex@case[#1]#2#3\endcase{\ifboolexpr{#1#2}{\bex@after_endswitch{#3}}}
+
+\long\def\bex@after_endswitch#1#2\endswitch{#1}
+\long\def\bex@otherwise#1\otherwise#2\endswitch{#1}
% \end{macrocode}
% \end{macro}
%
-% Restore original catcode:
-% \iffalse
-%<package>% Restore original catcode
-% \fi
+%
+% \begin{macro}{bex_ifsinglechar}
+% From \Xpackage{etextools}:
% \begin{macrocode}
-\bex@AtEnd
+\ifdefined\pdfmatch
+\long\def\bex_ifsinglechar#1#2{\csname @%
+ \ifnum\pdfmatch{\detokenize{^[#1]$}}{\detokenize{#2}}=1 first\else second\fi
+ oftwo\endcsname}
+\else
+\long\gdef\bex_ifsinglechar#1#2{\csname @%
+ \bex__ifnotblank#2$${%
+ \if\expandafter\@car\detokenize{#2}\relax\@nil\expandafter\@car\detokenize{#1}\string\\\@nil
+ \expandafter\expandafter\expandafter\ifx
+ \expandafter\expandafter\expandafter\\\expandafter\@cdr\detokenize{#2}\@nil\\%
+ first%
+ \else second%
+ \fi
+ \else second%
+ \fi}{second}$$oftwo\endcsname}
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macrocode}
+\bex@AtEnd\let\bex@AtEnd\@undefined
%</package>
% \end{macrocode}
%
% \subsection{Future developments : to do}
%
-% \xpackage{boolexpr} should work either with \eTeX{} or \eTeX-\LaTeX{}...
+% \thispackage should work either with \eTeX{} or \eTeX-\LaTeX{}...
%
% May be build a ``real'' |\NOT| operator.
-%
+%
% \begin{History}
%
+% \begin{Version}{2009/09/03 v3.0 -- \eTeX{}- and Xe\TeX{}- stable}
+% \item
+% Many bug fixed in \cmdref{switch}. Tested on \LaTeX, pdf\LaTeX{} and Xe\LaTeX.
+% \item
+% Optimization of test macros (hopefully no best solution exists...)
+% \item
+% Revision of this pdf documentation.
+% \end{Version}
+%
+% \begin{Version}{2009/08/31 v2.9}
+% \item
+% Added |\value| in the ``list of exceptions'' (\cs{bex@test_Eval})
+% Enhancement of |\switch| with the optional first argument (refer to the examples).
+% \end{Version}
+%
+% \begin{Version}{2009/08/13 v2.2}
+% \item
+% Small optimisation in \cs{bex@OR}
+% \end{Version}
+%
% \begin{Version}{2009/08/12 v2.1}
% \item
% Added the \cs{switch} syntax
% \item
-% Small bug (|\numexpr| forgotten in the ``list of exceptions'' (\cs{bex@test@Eval})
+% Small bug (|\numexpr| forgotten in the ``list of exceptions'' (\cs{bex@test_Eval})
% \item
% Redesigned tests for better compilation
% \end{Version}
@@ -1046,6 +1104,7 @@ boolexpr : a purely expandable boolean expressions and switch (eTeX)
%
% \end{History}
%
+% \clearpage
% \PrintIndex
%
% \label{LastPage}
diff --git a/Master/texmf-dist/source/latex/boolexpr/boolexpr.ins b/Master/texmf-dist/source/latex/boolexpr/boolexpr.ins
index f256e0b6bb6..16f207cba5a 100644
--- a/Master/texmf-dist/source/latex/boolexpr/boolexpr.ins
+++ b/Master/texmf-dist/source/latex/boolexpr/boolexpr.ins
@@ -26,7 +26,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: boolexpr 2009/08/12 v2.1 provides purely expandable boolean expressions and switch (eTeX)}
+\Msg{* Package: boolexpr 2009/09/03 v3.0 provides purely expandable boolean expressions and switch (eTeX)}
\Msg{************************************************************************}
\keepsilent