summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xifthen/xifthen.sty
blob: 081ac3ab696f9d0d0d0c7070a22576dc9e8dd581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
\def \@tempa $#1 #2 #3 #4 #5 #6 #7 ${%
  \def \filedate    {#4}%
  \def \fileversion {v#3}%
}
\@tempa $Id: xifthen.sty,v 1.1.1.1 2006/03/25 01:24:34 noirel Exp $
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xifthen}%
  [\filedate \space \fileversion \space Extended ifthen features]

\RequirePackage{etex}
\RequirePackage{calc}
\RequirePackage{ifthen}
\RequirePackage{ifmtarg}

\newcommand*{\TE@cnttest}[4]{%
  \TE@throw
  \noexpand \calc@assign@count{\@tempcnta}{\unexpanded{#1}}%
  \noexpand \calc@assign@count{\@tempcntb}{\unexpanded{#3}}%
  \noexpand \ifnum \@tempcnta#2\@tempcntb
  #4%
}

\newcommand*{\TE@dimtest}[4]{%
  \TE@throw
  \noexpand \calc@assign@skip{\@tempskipa}{\unexpanded{#1}}%
  \noexpand \calc@assign@skip{\@tempskipb}{\unexpanded{#3}}%
  \noexpand \ifdim \@tempskipa#2\@tempskipb
  #4%
}

\newcommand*{\TE@isnamedefined}[2]{%
  \TE@throw
  \noexpand \ifcsname #1\endcsname
  #2%
}

\newcommand*{\TE@isempty}[2]{%
  \TE@throw
  \noexpand \if FF\noexpand \@nameuse{fi}%
  \noexpand \@ifmtarg{\unexpanded{#1}}{%
    \noexpand \@nameuse{iftrue}%
  }{%
    \noexpand \@nameuse{iffalse}%
  }%
  #2%
}

\newcommand*{\TE@isequivalentto}[3]{%
  \TE@throw
  \noexpand \ifx \noexpand #1\noexpand#2%
  #3%
}

\newcommand*{\newtest}[1]{%
  \@ifnextchar[{%
    \@newtest{#1}%
  }{%
    \@newtest{#1}[0]%
  }%
}%

\newcommand*{\@newtest}{}
\def \@newtest #1[#2]#3{%
  \toks@ = {\(#3\)}%
  \TE@repl \or  \TE@or
  \TE@repl \and \TE@and
  \TE@repl \not \TE@neg
  \TE@repl \OR  \TE@or
  \TE@repl \AND \TE@and
  \TE@repl \NOT \TE@neg
  \edef \@tempa {%
    \unexpanded{\newcommand*{#1}[{#2}]}{\the \toks@}%
  }%
  \@tempa
}%

\newcommand*{\TE@hook}{%
  \let \isequivalentto = \TE@isequivalentto
  \let \isnamedefined = \TE@isnamedefined
  \let \isempty = \TE@isempty
  \let \cnttest = \TE@cnttest
  \let \dimtest = \TE@dimtest
}

\renewcommand{\ifthenelse}[1]{%
  \toks@{#1}%
  \TE@repl \or  \TE@or
  \TE@repl \and \TE@and
  \TE@repl \not \TE@neg
  \TE@repl \OR  \TE@or
  \TE@repl \AND \TE@and
  \TE@repl \NOT \TE@neg
  \begingroup
    \let \protect = \@unexpandable@protect
    \def \@setref ##1##2##3{\ifx ##1\relax \z@ \else \expandafter ##2##1\fi}%
    \def \value ##1{\the \csname c@##1\endcsname}%
    \let \equal = \TE@equal
    \let \( = \TE@lparen
    \let \) = \TE@rparen
    \let \isodd = \TE@odd
    \let \lengthtest = \TE@length
    \let \isundefined = \TE@undef
    \TE@hook
    \begingroup
      \let \@tempa = \relax
      \let \@tempb = \relax
      \xdef \@gtempa {\expandafter \TE@eval \the \toks@ \TE@endeval}%
    \endgroup
    \@gtempa
    \expandafter \endgroup
  \ifTE@val
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}

\endinput