[latex3-commits] [git/LaTeX3-latex3-latex3] main: Support primitive conditionals with \legacy_if:n(TF) (0263eca8b)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Mar 21 20:12:32 CET 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/0263eca8bb16c539993b85a828828dc4001db231

>---------------------------------------------------------------

commit 0263eca8bb16c539993b85a828828dc4001db231
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Mar 21 19:12:32 2022 +0000

    Support primitive conditionals with \legacy_if:n(TF)


>---------------------------------------------------------------

0263eca8bb16c539993b85a828828dc4001db231
 l3kernel/CHANGELOG.md |  3 +++
 l3kernel/l3legacy.dtx | 12 ++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 1ded95361..19354e46d 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -13,6 +13,9 @@ this project uses date-based 'snapshot' version identifiers.
 - Missing `\str_if_empty:n(TF)` (see issue \#1071)
 - Missing `\str_case:Nn(TF)` (see issue \#1071)
 
+### Changed
+- Definition of `\legacy_if:n(TF)` to support primitive conditionals
+
 ## [2022-02-24]
 
 ### Changed
diff --git a/l3kernel/l3legacy.dtx b/l3kernel/l3legacy.dtx
index fb04de0ad..5329a8f85 100644
--- a/l3kernel/l3legacy.dtx
+++ b/l3kernel/l3legacy.dtx
@@ -100,14 +100,18 @@
 %    \end{macrocode}
 %
 % \begin{macro}[EXP,pTF]{\legacy_if:n}
-%   A friendly wrapper.
+%   A friendly wrapper. We need to use the \cs{if:w} approach here, rather than
+%   testing against \tn{iftrue}/\tn{iffalse} as the latter approach fails for
+%   primitive conditionals such as \tn{ifmmode}. The \cs{reverse_if:N} here
+%   means that we get a slightly more useful error if the name is undefined.
 %    \begin{macrocode}
 \prg_new_conditional:Npnn \legacy_if:n #1 { p , T , F , TF }
   {
-    \exp_args:Nc \if_meaning:w { if#1 } \iftrue
-      \prg_return_true:
-    \else:
+    \exp_after:wN \reverse_if:N
+      \cs:w if#1 \cs_end:
       \prg_return_false:
+    \else:
+      \prg_return_true:
     \fi: 
   }
 %    \end{macrocode}





More information about the latex3-commits mailing list.