From f713ac513a897193c8b6ac8e34d55d8490fe270f Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Tue, 12 Apr 2022 03:04:20 +0000
Subject: CTAN sync 202204120304

---
 macros/latex/contrib/l3kernel/l3legacy.dtx | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

(limited to 'macros/latex/contrib/l3kernel/l3legacy.dtx')

diff --git a/macros/latex/contrib/l3kernel/l3legacy.dtx b/macros/latex/contrib/l3kernel/l3legacy.dtx
index fb04de0adf..534d37be27 100644
--- a/macros/latex/contrib/l3kernel/l3legacy.dtx
+++ b/macros/latex/contrib/l3kernel/l3legacy.dtx
@@ -43,7 +43,7 @@
 %    }^^A
 % }
 %
-% \date{Released 2022-02-24}
+% \date{Released 2022-04-10}
 %
 % \maketitle
 %
@@ -100,15 +100,19 @@
 %    \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:
-    \fi:
+    \else:
+      \prg_return_true:
+    \fi: 
   }
 %    \end{macrocode}
 % \end{macro}
-- 
cgit v1.2.3

