summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-10-03 14:55:33 +0000
committerKarl Berry <karl@freefriends.org>2009-10-03 14:55:33 +0000
commit4d18074405a67946d5505fd5e0836e115d220541 (patch)
tree02a7acd701c05291a6d3f885ae0ca9ebc4ff1fe1 /Master/texmf-dist/tex
parent95501215cb9ee689510d34f43334f95bdc383231 (diff)
boolexpr update (30sep09)
git-svn-id: svn://tug.org/texlive/trunk@15601 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/boolexpr/boolexpr.sty122
1 files changed, 67 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/boolexpr/boolexpr.sty b/Master/texmf-dist/tex/latex/boolexpr/boolexpr.sty
index 202b064b961..1acae56abd9 100644
--- a/Master/texmf-dist/tex/latex/boolexpr/boolexpr.sty
+++ b/Master/texmf-dist/tex/latex/boolexpr/boolexpr.sty
@@ -24,7 +24,7 @@
%%
%% boolexpr : a purely expandable boolean expressions and switch (eTeX)
\ProvidesPackage{boolexpr}
- [2009/09/03 v3.0 Purely expandable boolean expressions and switch (eTeX)]
+ [2009/09/30 v3.1 Purely expandable boolean expressions and switch (eTeX)]
% Make a colon (:) of catcode 4 (used as delimiter)
\let\bex@AtEnd\@empty
@@ -36,37 +36,42 @@
\catcode#1 #2\relax
}
\TMP@EnsureCode{95}{11}% _
-\TMP@EnsureCode{36}{12}% $
+\TMP@EnsureCode{47}{8}% / etextool delimiter
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{61}{12}% =
\TMP@EnsureCode{62}{12}% >
+\TMP@EnsureCode{43}{12}% -
+\TMP@EnsureCode{45}{12}% +
+\TMP@EnsureCode{58}{8}% : delimitor
% Three helper macros
\let\bex@truepart\@firstoftwo
\let\bex@falsepart\@secondoftwo
-\long\def\bex__ifnotblank#1#2$#3#4#5$${#4}
+\long\def\bex@nbk#1#2/#3#4#5//{#4}
+\long\def\bex@ifoptchar#1[#2/#3#{\csname @\if @\detokenize{#1#2}@%
+ first\else second\fi oftwo\endcsname}
% \bex@rel tests each atomic expression: choose which evaluation macro to use first
\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$}
+ \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}$$}$$}$$}$$}$$}$$}}
+ \noexpand\boolexpr!}\@ehd}//}//}//}//}//}//}}
% Tests macros to determine the type of each atomic expression
-\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${%
+\def\bex@test_neq#1<>#2/{\bex@nbk#2/}
+\def\bex@test_eq#1=#2/{\bex@nbk #2/}
+\def\bex@test_infeq#1<=#2/{\bex@nbk #2/}
+\def\bex@test_inf#1<#2/{\bex@nbk #2/}
+\def\bex@test_supeq#1>=#2/{\bex@nbk #2/}
+\def\bex@test_sup#1>#2/{\bex@nbk #2/}
+\long\def\bex@test_eval#1#2/{%
\ifcat\noexpand#1\relax% #1 is a control sequence
\bex@test_Eval{#1}
\else \expandafter\@secondoftwo
@@ -85,73 +90,80 @@
% Evaluation macro that evaluates an atomic expression depending on its type:
\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@%
+\long\def\bex@false_or_true#1{\csname bex@%
\ifnum\numexpr#1 false\else true\fi part\endcsname}
-\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@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}}
% \bex@OR splits the string to evaluate into two parts: before the first \OR and after
-\long\def\bex@OR#1\OR#2${\bex@AND{#2}#1\AND$}
+\long\def\bex@OR#1\OR#2:{\bex@AND{#2}#1\AND:}
% \bex@AND splits the string to evaluate into two parts: before the first \AND and after:
-\long\def\bex@AND#1#2\AND#3${%
+\long\def\bex@AND#1#2\AND#3:{%
\bex@rel{#2}
- {\bex__ifnotblank #3$${\bex@ANDAND{#1}#3$}{+0}$$}
- {\bex__ifnotblank #1$${\bex@OR#1$}{+1}$$}}
+ {\bex@nbk #3//{\bex@ANDAND{#1}#3:}{+0}//}
+ {\bex@nbk #1//{\bex@OR#1:}{+1}//}}
% \bex@ANDAND evaluate successive atomic expressions related by \AND:
-\long\def\bex@ANDAND#1#2\AND#3${%
+\long\def\bex@ANDAND#1#2\AND#3:{%
\bex@rel{#2}
- {\bex__ifnotblank #3$${\bex@ANDAND{#1}#3$}{+0}$$}
- {\bex__ifnotblank #1$${\bex@OR#1$}{+1}$$}}
+ {\bex@nbk #3//{\bex@ANDAND{#1}#3:}{+0}//}
+ {\bex@nbk #1//{\bex@OR#1:}{+1}//}}
% \boolexpr: the entry point for evaluating boolean expressions
-\newcommand\boolexpr[1]{\bex__ifnotblank #1$${\numexpr\bex@OR#1 \OR$}{+1}$$}
+\newcommand\boolexpr[1]{\bex@nbk #1//{\numexpr\bex@OR#1\OR:}{+1}//}
% \ifboolexpr: the LaTeX form of \boolexpr tests
\newcommand\ifboolexpr[1]{\bex@true_or_false{\boolexpr{#1}=0}}
-\long\def \switch#1\endswitch {\bex__ifnotblank#1$${\bex@switch_opt#1 \endswitch}{}$$}
-\long\def \bex@switch_opt#1#2\endswitch {\bex_ifsinglechar [{#1}%
+\long\def \switch#1\endswitch {\bex@nbk#1//{\bex@switch_opt#1\endswitch}{}//}
+\long\def \bex@switch_opt#1#2\endswitch{\bex@ifoptchar#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]#2\otherwise#3\endswitch{%
\bex@switch_case[{#1}]#2\case\endswitch
- {\bex__ifnotblank#3$${\bex@otherwise#3\endswitch}{}$$}
+ {\bex@nbk#3//{\bex@otherwise#3\endswitch}{}//}
\endswitch}
-\def\bex@switch_case[#1]#2\case#3\endswitch{\bex__ifnotblank#2$$%
+\def\bex@switch_case[#1]#2\case#3\endswitch{\bex@nbk#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$$}$$}
+ {\bex@nbk#3//{\bex@switch_case[{#1}]#3\endswitch}\@firstoftwo//}}%
+ {\bex@nbk#3//{\bex@switch_case[{#1}]#3\endswitch}\@firstoftwo//}//}
\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}
-\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
+\long\def\bex@pdfmatch#1#2{\ifnum\pdfmatch{#2}{#1}=0 1\else0\fi}
+\long\def\bex@ifempty#1{\if\relax\detokenize{#1}\relax0\else1\fi}
+\long\def\bex_ifempty#1{\csname @\if\relax\detokenize{#1}\relax first\else second\fi oftwo\endcsname}
+\long\def\bex@ifblank#1{\bex@nbk#1//10//}
+\long\def\bex@ifx#1#2{\bex__ifx#1#2//}
+\long\def\bex_ifx#1#2#3/#4#5#6//{\bex@nbk#6//{\ifx#1#2\bex_else#5\else\bex_fi#6\fi}{#5}//}
+\long\def\bex_else#1\else#2\fi{\fi#1}
+\long\def\bex_fi#1\fi{\fi#1}
+\long\def\bex@comp#1{\bex@ifoptchar#1/[/\bex@c@mp{\bex@c@mp@[\numexpr]}}
+\long\def\bex@c@mp[#1#2]#3#4#5{%
+ \bex_ifempty{#2}{%
+ \ifx #1\dimexpr \bex@c@mp@\ifdim\dimexpr{#3}{#4}{#5}%
+ \else\ifx #1\numexpr \bex@c@mp@\ifnum\numexpr{#3}{#4}{#5}%
+ \else\ifx #1\glueexpr \bex@c@mp@\ifdim\glueexpr{#3}{#4}{#5}%
+ \else\ifx #1\muexpr \bex@c@mp@\ifdim\muexpr{#3}{#4}{#5}%
+ \else\ifx #1\number \bex@c@mp@\ifnum\numexpr{#3}{#4}{#5}%
+ \else\PackageError{boolexpr}{%
+ Invalid comparison test while scanning \string\bex@comp\MessageBreak
+ found: \detokenize{#1}}%
+ \fi\fi\fi\fi\fi}%
+ {\PackageError{boolexpr}{Invalid comparison test while scanning \string\bex@comp\MessageBreak
+ found: \detokenize{#1}}}}
+\long\def\bex@c@mp@#1#2#3#4#5{#1#2#3#4#5 0\else 1\fi}
\bex@AtEnd\let\bex@AtEnd\@undefined
\endinput
%%