| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% The LaTeX Project and any individual authors listed elsewhere |
| 5 |
% in this file. |
| 6 |
% |
| 7 |
% This file is part of the LaTeX base system. |
| 8 |
% ------------------------------------------- |
| 9 |
% |
| 10 |
% It may be distributed and/or modified under the |
| 11 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 12 |
% of this license or (at your option) any later version. |
| 13 |
% The latest version of this license is in |
| 14 |
% https://www.latex-project.org/lppl.txt |
| 15 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 16 |
% version 2008 or later. |
| 17 |
% |
| 18 |
% This file has the LPPL maintenance status "maintained". |
| 19 |
% |
| 20 |
% The list of all files belonging to the LaTeX base distribution is |
| 21 |
% given in the file `manifest.txt'. See also `legal.txt' for additional |
| 22 |
% information. |
| 23 |
% |
| 24 |
% The list of derived (unpacked) files belonging to the distribution |
| 25 |
% and covered by LPPL is defined by the unpacking scripts (with |
| 26 |
% extension .ins) which are part of the distribution. |
| 27 |
% |
| 28 |
% \fi |
| 29 |
% |
| 30 |
% \iffalse |
| 31 |
%%% From File: ltcntrl.dtx |
| 32 |
%<*driver> |
| 33 |
% \fi |
| 34 |
\ProvidesFile{ltcntrl.dtx} |
| 35 |
[2020/12/04 v1.0h LaTeX Kernel (program control)] |
| 36 |
% \iffalse |
| 37 |
\documentclass{ltxdoc} |
| 38 |
\GetFileInfo{ltcntrl.dtx} |
| 39 |
\title{\filename} |
| 40 |
\date{\filedate} |
| 41 |
\author{% |
| 42 |
Johannes Braams\and |
| 43 |
David Carlisle\and |
| 44 |
Alan Jeffrey\and |
| 45 |
Leslie Lamport\and |
| 46 |
Frank Mittelbach\and |
| 47 |
Chris Rowley\and |
| 48 |
Rainer Sch\"opf} |
| 49 |
\begin{document} |
| 50 |
\MaintainedByLaTeXTeam{latex} |
| 51 |
\maketitle |
| 52 |
\DocInput{\filename} |
| 53 |
\end{document} |
| 54 |
%</driver> |
| 55 |
% \fi |
| 56 |
% |
| 57 |
% |
| 58 |
% \changes{v1.0a}{1994/05/16}{(ASAJ) Split from ltinit.dtx.} |
| 59 |
% \changes{v1.0b}{1994/11/17} |
| 60 |
% {\cs{@tempa} to \cs{reserved@a}} |
| 61 |
% \changes{v1.0c}{1994/11/28} |
| 62 |
% {Documentation improvements} |
| 63 |
% |
| 64 |
% \section{Program control structure} |
| 65 |
% |
| 66 |
% This section defines a number of control structure macros, such as |
| 67 |
% while-loops and for-loops. |
| 68 |
% |
| 69 |
% \MaybeStop{} |
| 70 |
% |
| 71 |
% \begin{oldcomments} |
| 72 |
% \begin{macrocode} |
| 73 |
%<*2ekernel> |
| 74 |
\message{control,} |
| 75 |
% \end{macrocode} |
| 76 |
% |
| 77 |
% \@whilenum TEST \do {BODY} |
| 78 |
% \@whiledim TEST \do {BODY} : These implement the loop |
| 79 |
% while TEST do BODY od |
| 80 |
% where TEST is a TeX \ifnum or \ifdim test, respectively. |
| 81 |
% They are optimized for the normal case of TEST initially false. |
| 82 |
% |
| 83 |
% \@whilesw SWITCH \fi {BODY} : Implements the loop |
| 84 |
% while SWITCH do BODY od |
| 85 |
% Optimized for normal case of SWITCH initially false. |
| 86 |
% |
| 87 |
% \@for NAME := LIST \do {BODY} : Assumes that LIST expands to A1,A2, |
| 88 |
% ... ,An . |
| 89 |
% Executes BODY n times, with NAME = Ai on the i-th iteration. |
| 90 |
% Optimized for the normal case of n = 1. Works for n=0. |
| 91 |
% |
| 92 |
% \@tfor NAME := LIST \do {BODY} |
| 93 |
% if, before expansion, LIST = T1 ... Tn where each Ti is a |
| 94 |
% token or {...}, then executes BODY n times, with NAME = Ti |
| 95 |
% on the i-th iteration. Works for n=0. |
| 96 |
% |
| 97 |
% NOTES: 1. These macros use no \@temp sequences. |
| 98 |
% 2. These macros do not work if the body contains anything that |
| 99 |
% looks syntactically to TeX like an improperly balanced \if |
| 100 |
% \else \fi. |
| 101 |
% |
| 102 |
% \@whilenum TEST \do {BODY} == |
| 103 |
% BEGIN |
| 104 |
% if TEST |
| 105 |
% then BODY |
| 106 |
% \@iwhilenum{TEST \relax BODY} |
| 107 |
% END |
| 108 |
% |
| 109 |
% \@iwhilenum {TEST BODY} == |
| 110 |
% BEGIN |
| 111 |
% if TEST |
| 112 |
% then BODY |
| 113 |
% \@nextwhile = def(\@iwhilenum) |
| 114 |
% else \@nextwhile = def(\@whilenoop) |
| 115 |
% fi |
| 116 |
% \@nextwhile {TEST BODY} |
| 117 |
% END |
| 118 |
% |
| 119 |
% \@whilesw SWITCH \fi {BODY} == |
| 120 |
% BEGIN |
| 121 |
% if SWITCH |
| 122 |
% then BODY |
| 123 |
% \@iwhilesw {SWITCH BODY}\fi |
| 124 |
% fi |
| 125 |
% END |
| 126 |
% |
| 127 |
% \@iwhilesw {SWITCH BODY} \fi == |
| 128 |
% BEGIN |
| 129 |
% if SWITCH |
| 130 |
% then BODY |
| 131 |
% \@nextwhile = def(\@iwhilesw) |
| 132 |
% else \@nextwhile = def(\@whileswnoop) |
| 133 |
% fi |
| 134 |
% \@nextwhile {SWITCH BODY} \fi |
| 135 |
% END |
| 136 |
% |
| 137 |
% \end{oldcomments} |
| 138 |
% |
| 139 |
% \begin{macro}{\@whilenoop} |
| 140 |
% \begin{macro}{\@whilenum} |
| 141 |
% \begin{macro}{\@iwhilenum} |
| 142 |
% \changes{v1.0f}{1995/07/09}{Reimplemented using Kabelschacht method} |
| 143 |
% \changes{v1.0g}{1995/08/16}{Removed \cs{@whilenoop}} |
| 144 |
% \changes{v1.0g}{1995/08/16}{Made defs long} |
| 145 |
% \begin{macrocode} |
| 146 |
\long\def\@whilenum#1\do #2{\ifnum #1\relax #2\relax\@iwhilenum{#1\relax |
| 147 |
#2\relax}\fi} |
| 148 |
\long\def\@iwhilenum#1{\ifnum #1\expandafter\@iwhilenum |
| 149 |
\else\expandafter\@gobble\fi{#1}} |
| 150 |
% \end{macrocode} |
| 151 |
% \end{macro} |
| 152 |
% \end{macro} |
| 153 |
% \end{macro} |
| 154 |
% |
| 155 |
% \begin{macro}{\@whiledim} |
| 156 |
% \begin{macro}{\@iwhiledim} |
| 157 |
% \changes{v1.0f}{1995/07/09}{Reimplemented using Kabelschacht method} |
| 158 |
% \changes{v1.0g}{1995/08/16}{Removed \cs{@whilenoop}} |
| 159 |
% \changes{v1.0g}{1995/08/16}{Made defs long} |
| 160 |
% \begin{macrocode} |
| 161 |
\long\def\@whiledim#1\do #2{\ifdim #1\relax#2\@iwhiledim{#1\relax#2}\fi} |
| 162 |
\long\def\@iwhiledim#1{\ifdim #1\expandafter\@iwhiledim |
| 163 |
\else\expandafter\@gobble\fi{#1}} |
| 164 |
% \end{macrocode} |
| 165 |
% \end{macro} |
| 166 |
% \end{macro} |
| 167 |
% |
| 168 |
% \begin{macro}{\@whileswnoop} |
| 169 |
% \begin{macro}{\@whilesw} |
| 170 |
% \begin{macro}{\@iwhilesw} |
| 171 |
% \changes{v1.0f}{1995/07/09}{Reimplemented using Kabelschacht method} |
| 172 |
% \changes{v1.0g}{1995/08/16}{Removed \cs{@whileswnoop}} |
| 173 |
% \begin{macrocode} |
| 174 |
\long\def\@whilesw#1\fi#2{#1#2\@iwhilesw{#1#2}\fi\fi} |
| 175 |
\long\def\@iwhilesw#1\fi{#1\expandafter\@iwhilesw |
| 176 |
\else\@gobbletwo\fi{#1}\fi} |
| 177 |
% \end{macrocode} |
| 178 |
% \end{macro} |
| 179 |
% \end{macro} |
| 180 |
% \end{macro} |
| 181 |
% |
| 182 |
% \begin{oldcomments} |
| 183 |
% |
| 184 |
% \@for NAME := LIST \do {BODY} == |
| 185 |
% BEGIN \@forloop expand(LIST),\@nil,\@nil \@@ NAME {BODY} END |
| 186 |
% |
| 187 |
% \@forloop CAR, CARCDR, CDRCDR \@@ NAME {BODY} == |
| 188 |
% BEGIN |
| 189 |
% NAME = CAR |
| 190 |
% if def(NAME) = def(\@nnil) |
| 191 |
% else BODY; |
| 192 |
% NAME = CARCDR |
| 193 |
% if def(NAME) = def(\@nnil) |
| 194 |
% else BODY |
| 195 |
% \@iforloop CDRCDR \@@ NAME \do {BODY} |
| 196 |
% fi |
| 197 |
% fi |
| 198 |
% END |
| 199 |
% |
| 200 |
% \@iforloop CAR, CDR \@@ NAME {BODY} = |
| 201 |
% NAME = CAR |
| 202 |
% if def(NAME) = def(\@nnil) |
| 203 |
% then \@nextwhile = def(\@fornoop) |
| 204 |
% else BODY ; |
| 205 |
% \@nextwhile = def(\@iforloop) |
| 206 |
% fi |
| 207 |
% \@nextwhile name cdr {body} |
| 208 |
% |
| 209 |
% \@tfor NAME := LIST \do {BODY} |
| 210 |
% = \@tforloop LIST \@nil \@@ NAME {BODY} |
| 211 |
% |
| 212 |
% \@tforloop car cdr \@@ name {body} = |
| 213 |
% name = car |
| 214 |
% if def(name) = def(\@nnil) |
| 215 |
% then \@nextwhile == \@fornoop |
| 216 |
% else body ; |
| 217 |
% \@nextwhile == \@forloop |
| 218 |
% fi |
| 219 |
% \@nextwhile name cdr {body} |
| 220 |
% \end{oldcomments} |
| 221 |
% |
| 222 |
% \begin{macro}{\@nnil} |
| 223 |
% \begin{macrocode} |
| 224 |
\def\@nnil{\@nil} |
| 225 |
% \end{macrocode} |
| 226 |
% \end{macro} |
| 227 |
% |
| 228 |
% \begin{macro}{\@empty} |
| 229 |
% \begin{macrocode} |
| 230 |
\def\@empty{} |
| 231 |
% \end{macrocode} |
| 232 |
% \end{macro} |
| 233 |
% |
| 234 |
% \begin{macro}{\@fornoop} |
| 235 |
% \changes{v1.0g}{1995/08/16}{Made defs long} |
| 236 |
% \changes{v1.0h}{2007/08/06}{Really make defs long} |
| 237 |
% \begin{macrocode} |
| 238 |
\long\def\@fornoop#1\@@#2#3{} |
| 239 |
% \end{macrocode} |
| 240 |
% \end{macro} |
| 241 |
% |
| 242 |
% \begin{macro}{\@for} |
| 243 |
% \changes{v1.0d}{1995/04/24} |
| 244 |
% {Don't expand second argument with \cs{edef}: /1317 (DPC)} |
| 245 |
% \begin{macrocode} |
| 246 |
\long\def\@for#1:=#2\do#3{% |
| 247 |
\expandafter\def\expandafter\@fortmp\expandafter{#2}% |
| 248 |
\ifx\@fortmp\@empty \else |
| 249 |
\expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi} |
| 250 |
% \end{macrocode} |
| 251 |
% \end{macro} |
| 252 |
% |
| 253 |
% \begin{macro}{\@forloop} |
| 254 |
% \changes{v1.0g}{1995/08/16}{Made defs long} |
| 255 |
% \begin{macrocode} |
| 256 |
\long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else |
| 257 |
#5\def#4{#2}\ifx #4\@nnil \else#5\@iforloop #3\@@#4{#5}\fi\fi} |
| 258 |
% \end{macrocode} |
| 259 |
% \end{macro} |
| 260 |
% |
| 261 |
% \begin{macro}{\@iforloop} |
| 262 |
% \changes{v1.0f}{1995/07/09}{Reimplemented using Kabelschacht method} |
| 263 |
% \changes{v1.0g}{1995/08/16}{Made defs long} |
| 264 |
% \begin{macrocode} |
| 265 |
\long\def\@iforloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil |
| 266 |
\expandafter\@fornoop \else |
| 267 |
#4\relax\expandafter\@iforloop\fi#2\@@#3{#4}} |
| 268 |
% \end{macrocode} |
| 269 |
% \end{macro} |
| 270 |
% |
| 271 |
% \begin{macro}{\@tfor} |
| 272 |
% \changes{LaTeX209}{1991/10/17} |
| 273 |
% {(Rms) \cs{xdef} replaced by \cs{def} |
| 274 |
% (See FMi's array.doc)} |
| 275 |
% \changes{v1.0c}{1994/03/13} |
| 276 |
% {(DPC) Add \cs{@tf@r} so a single group is |
| 277 |
% correctly treated.} |
| 278 |
% \changes{v1.0f}{1995/07/09}{Reimplemented using Kabelschacht method} |
| 279 |
% \changes{v1.0g}{1995/08/16}{Made defs long} |
| 280 |
% \begin{macrocode} |
| 281 |
\def\@tfor#1:={\@tf@r#1 } |
| 282 |
\long\def\@tf@r#1#2\do#3{\def\@fortmp{#2}\ifx\@fortmp\space\else |
| 283 |
\@tforloop#2\@nil\@nil\@@#1{#3}\fi} |
| 284 |
\long\def\@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil |
| 285 |
\expandafter\@fornoop \else |
| 286 |
#4\relax\expandafter\@tforloop\fi#2\@@#3{#4}} |
| 287 |
% \end{macrocode} |
| 288 |
% \end{macro} |
| 289 |
% |
| 290 |
% \begin{macro}{\@break@tfor} |
| 291 |
% Break out of a |\@tfor| loop. This should be called \emph{inside} |
| 292 |
% the scope of an |\if|. See |\@iffileonpath| for an example. |
| 293 |
% \changes{v1.0l}{1994/05/02}{Macro added (from ltfiles.dtx)} |
| 294 |
% \changes{v1.0g}{1995/08/16}{Made long} |
| 295 |
% \begin{macrocode} |
| 296 |
\long\def\@break@tfor#1\@@#2#3{\fi\fi} |
| 297 |
% \end{macrocode} |
| 298 |
% \end{macro} |
| 299 |
% |
| 300 |
% \begin{macro}{\@removeelement} |
| 301 |
% Removes an element from a comma-separated list and puts it into |
| 302 |
% a control sequence, called as |
| 303 |
% |\@removeelement{|\meta{element}|}{|\meta{list}|}{|\meta{cs}|}|. |
| 304 |
% Due to the implementation method the \meta{element} is not allowed |
| 305 |
% to contain braces. |
| 306 |
% \begin{macrocode} |
| 307 |
\def\@removeelement#1#2#3{% |
| 308 |
\def\reserved@a##1,#1,##2\reserved@a{##1,##2\reserved@b}% |
| 309 |
\def\reserved@b##1,\reserved@b##2\reserved@b{% |
| 310 |
\ifx,##1\@empty\else##1\fi}% |
| 311 |
\edef#3{% |
| 312 |
\expandafter\reserved@b\reserved@a,#2,\reserved@b,#1,\reserved@a}} |
| 313 |
% \end{macrocode} |
| 314 |
% \end{macro} |
| 315 |
% |
| 316 |
% |
| 317 |
% \changes{v1.0e}{1995/04/29}{Removed unused defs for |
| 318 |
% \cs{@setprotect} and \cs{@resetprotect}} |
| 319 |
% \changes{v1.0e}{1995/04/29}{Moved init of \cs{protect} |
| 320 |
% to ltdefns.dtx} |
| 321 |
% \begin{macrocode} |
| 322 |
%</2ekernel> |
| 323 |
% \end{macrocode} |
| 324 |
% |
| 325 |
%\Finale |
| 326 |
\endinput |