From bdead7ff97ef61cca4f56b4a153cc85e18c41fda Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 15 Jan 2021 03:05:16 +0000 Subject: CTAN sync 202101150305 --- macros/luatex/optex/base/if-macros.opm | 72 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'macros/luatex/optex/base/if-macros.opm') diff --git a/macros/luatex/optex/base/if-macros.opm b/macros/luatex/optex/base/if-macros.opm index 1745baa7ac..0e7e401558 100644 --- a/macros/luatex/optex/base/if-macros.opm +++ b/macros/luatex/optex/base/if-macros.opm @@ -1,17 +1,17 @@ -%% This is part of OpTeX project, see http://petr.olsak.net/optex +%% This is part of the OpTeX project, see http://petr.olsak.net/optex \_codedecl \newif {Special if-macros, is-macros and loops <2020-05-22>} % preloaded in format \_doc ---------------------------- \secc Classical \code{\\newif} - The \`\newif` macro implements boolean value. + The \`\newif` macro implements boolean value. It works as in plain \TeX. It means that after `\newif\ifxxx` you can use `\xxxtrue` or `\xxxfalse` to set the boolean value and use `\ifxxx true\else false\fi` to test this value. The default value is false. The macro \`\_newifi` enables to declare `\_ifxxx` and to use `\_xxxtrue` and - `\_xxxfalse`. This means that it is usable for internal name space + `\_xxxfalse`. This means that it is usable for the internal namespace (`_`prefixed macros). \_cod ---------------------------- @@ -48,7 +48,7 @@ better (you can use `\else` clause after the `\ifsomething`). There are public version `\loop...\repeat` and private version - \`\_loop` ...\`\_repeat`. You cannot mix both versions in one loop. + \`\_loop` ...\`\_repeat`. You cannot mix both versions in one loop. The `\loop` macro keeps its original plain TeX meaning. It is not expandable and nested `\loop`s are possible only in a \TeX/ group. @@ -81,7 +81,7 @@ private variants use \`\_do` separator instead `\do` separator. \_cod ----------------------------- -\_newcount\_frnum % the numeric variable used in \fornum +\_newcount\_frnum % the numeric variable used in \fornum \_def\_do{\_doundefined} % we need to ask \_ifx#1\_do ... \_long\_def\_foreach #1\_do #2#{\_isempty{#2}\_iftrue @@ -101,26 +101,26 @@ \`\fornumstep` `: ..` \`\do` `{}` repeats `` for each number from `` to `` (with step `` or with step one). The `` can include `#1` which is substituted by - current number. The sequence `..` can be decreasing too. - The macro is expandable. + current number. The , , parameters can be numeric expressions. + The macro is expandable.\nl + The test in the \`\_fornumB` says: if ( $\string<$ + AND is positive) or if ( $>$ AND is + negative) then close loop by `\_getforstack`. Sorry, the condition is + writen by somewhat cryptoid \TeX/ language. \_cod ----------------------------- \_def\_fornum#1..#2\_do{\_fornumstep 1:#1..#2\_do} \_long\_def\_fornumstep#1:#2..#3\_do#4{\_putforstack \_immediateassigned{% \_gdef\_fbody##1{#4}% - \_gdef\_fornumsgn{}% - \_gdef\_fornumrel{<}% \_global\_frnum=\_numexpr#2\_relax - \_ifnum\_numexpr#3<\_frnum \_gdef\_fornumrel{>}\_fi %decreasing sequence - \_ifnum\_numexpr#1\_fornumrel0 \_gdef\_fornumsgn{-}\_fi % correction }% - \_fornumB{#3}{#1}% + \_ea\_fornumB\_ea{\_the\_numexpr#3\_ea}\_ea{\_the\_numexpr#1}% } -\_def\_fornumB #1#2{\_ifnum\_numexpr#1\_fornumrel\_frnum \_getforstack \_else - \_ea\_fbody\_ea{\_the\_frnum}% - \_immediateassignment\_global\_advance\_frnum by\_numexpr\_fornumsgn#2\_relax - \_afterfi{\_fornumB{#1}{#2}}\_fi +\_def\_fornumB #1#2{\_ifnum#1\_ifnum#2>0<\_else>\_fi \_frnum \_getforstack + \_else \_ea\_fbody\_ea{\_the\_frnum}% + \_immediateassignment\_global\_advance\_frnum by#2 + \_afterfi{\_fornumB{#1}{#2}}\_fi } \_def\fornum#1..#2\do{\_fornumstep 1:#1..#2\_do} \_def\fornumstep#1:#2..#3\do{\_fornumstep #1:#2..#3\_do} @@ -132,11 +132,11 @@ \begtt \foreach ABC \do {\fornum 1..5 \do {letter:#1, number: ##1. }} \endtt - Implementation note: + Implementation note: we cannot use \TeX/-groups for nesting levels because we want to do the macros expandable. We must implement a special for-stack which saves the data needed by `\foreach` and `\fornum`. The \`\_putforstack` is used - when `\for*` is initialized and \`\_getforstack` is used when the + when `\for*` is initialized and \`\_getforstack` is used when the `\for*` macro ends. The \`\_forlevel` variable keeps the current nesting level. If it is zero, then we need not save nor restore any data. \_cod ---------------------------- @@ -146,7 +146,7 @@ \_ifnum\_forlevel>0 \_sxdef{_frnum:\_the\_forlevel\_ea}{\_the\_frnum}% \_global\_slet{_fbody:\_the\_forlevel}{_fbody}% - \_fi + \_fi \_global\_advance\_forlevel by1 }} \_def\_getforstack{\_immediateassigned{% @@ -183,28 +183,28 @@ \secc Is-macros There are a collection of macros \^`\isempty`, \^`\istoksempty`, \^`\isequal`, \^`\ismacro`, - \^`\isdefined`, \^`\isinlist` and \^`\isfile` + \^`\isdefined`, \^`\isinlist`, \^`\isfile` and \^`\isfont` with common syntax: \begtt \catcode`\<=13 - \issomething \iftrue \else \fi - or + \issomething \iftrue \else \fi + or \issomething \iffalse \else \fi \endtt The `\else` part is optional. The `` is processed if `\issomething` generates true condition. The `` is processed if `\issomething` generates false condition. - The `\iftrue` or `\iffalse` is an integral part of this syntax + The `\iftrue` or `\iffalse` is an integral part of this syntax because we need to keep skippable nested `\if` conditions. - Implementation note: + Implementation note: we read this `\iftrue` or `\iffalse` into unseparated parameter and repeat it because we need to remove an optional space before this command. \medskip\noindent \`\isempty` `{}\iftrue` is true if the `` is empty. This macro is expandable.\nl - \`\istoksempty` `\iftrue` + \`\istoksempty` `\iftrue` is true if the `` is empty. It is expandable. \_cod ---------------------------- @@ -213,14 +213,14 @@ \_public \isempty \istoksempty ; \_doc ---------------------------- - \`\isequal` `{}{}\iftrue` + \`\isequal` `{}{}\iftrue` is true if the and are equal, only from strings point of view, category codes are ignored. The macro is expandable. \_cod ---------------------------- \_def\_isequal#1#2#3{\_directlua{% - if "\_luaescapestring{\_detokenize{#1}}"=="\_luaescapestring{\_detokenize{#2}}" + if "\_luaescapestring{\_detokenize{#1}}"=="\_luaescapestring{\_detokenize{#2}}" then else tex.print("\_nbb unless") end}#3} \_public \isequal ; @@ -242,11 +242,11 @@ \_doc ---------------------------- \`\isinlist` `\list{}\iftrue` is true if the - `` is included the macro body of the `\list`. - The category code are relevant here. The macro is not expandable. + `` is included the macro body of the `\list`. + The category codes are relevant here. The macro is not expandable. \_cod ---------------------------- -\_long\_def\_isinlist#1#2{\_begingroup +\_long\_def\_isinlist#1#2{\_begingroup \_long\_def\_tmp##1#2##2\_end/_% {\_endgroup\_if\_relax\_detokenize{##2}\_relax \_ea\_unless\_fi}% \_ea\_tmp#1\_endlistsep#2\_end/_% @@ -269,8 +269,8 @@ \_doc ----------------------------- \`\isfont` `{}\iftrue` - is true if given font exists. The result of this testing - is saved to the \`\_ifexistfam`. + is true if a given font exists. The result of this testing + is saved to the \`\_ifexistfam`. \_cod ----------------------------- \_newifi \_ifexistfam @@ -285,9 +285,9 @@ \_public \isfont ; \_doc ---------------------------- - The last macro \`\isnextchar` `{}{}` - has different syntax than all others is-macros. - It executes `` if next character is equal to . + The last macro \`\isnextchar` `{}{}` + has a different syntax than all other is-macros. + It executes `` if next character is equal to . Else the `` is executed. The macro is not expandable. \_cod ---------------------------- @@ -299,7 +299,7 @@ \_public \isnextchar ; -\_endcode +\_endcode 2020-05-22 \foreach, \fornum: all settings are global, independent on TeX group 2020-05-06 \isnextchar: \let\tmp=#1 -> \let\tmp= #1 (bug fix, #1 should be space) -- cgit v1.2.3