[latex3-commits] [git/LaTeX3-latex3-latex3] gh664-legacy-if: Implement \legacy_if_set_true:n and \legacy_if_set:nn (fixes #664) (74493ff73)
Bruno Le Floch
blflatex at gmail.com
Wed May 12 22:35:42 CEST 2021
Repository : https://github.com/latex3/latex3
On branch : gh664-legacy-if
Link : https://github.com/latex3/latex3/commit/74493ff73cb9695ae2dc79a80808bd01f9731b1f
>---------------------------------------------------------------
commit 74493ff73cb9695ae2dc79a80808bd01f9731b1f
Author: Bruno Le Floch <blflatex at gmail.com>
Date: Wed May 12 22:34:56 2021 +0200
Implement \legacy_if_set_true:n and \legacy_if_set:nn (fixes #664)
>---------------------------------------------------------------
74493ff73cb9695ae2dc79a80808bd01f9731b1f
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3legacy.dtx | 56 ++++++++++++++++++++++
l3kernel/testfiles/m3legacy001.lvt | 56 ++++++++++++++++++++++
.../testfiles/{m3pdf001.tlg => m3legacy001.tlg} | 18 ++++---
4 files changed, 121 insertions(+), 10 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 69f8cd9f4..dd771da18 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -14,6 +14,7 @@ this project uses date-based 'snapshot' version identifiers.
`\color_log:n`, `\group_show_list:`, `\group_log_list:`,
`\ior_show:N`, `\ior_log:N`, `\iow_show:N`, `\iow_log:N`,
`\tl_log_analysis:N`, `\tl_log_analysis:n`
+- `\legacy_if_set_true:n`, `\legacy_if_set_false:n`, `\legacy_if_set:nn`
## [2021-05-11]
diff --git a/l3kernel/l3legacy.dtx b/l3kernel/l3legacy.dtx
index 05b98fed5..c00116751 100644
--- a/l3kernel/l3legacy.dtx
+++ b/l3kernel/l3legacy.dtx
@@ -63,6 +63,28 @@
% \meta{name} of the conditional should \emph{omit} the leading \texttt{if}.
% \end{function}
%
+% \begin{function}[added = 2021-05-10]
+% {
+% \legacy_if_set_true:n, \legacy_if_set_false:n,
+% \legacy_if_gset_true:n, \legacy_if_gset_false:n
+% }
+% \begin{syntax}
+% \cs{legacy_if_set_true:n} \Arg{name}
+% \cs{legacy_if_set_false:n} \Arg{name}
+% \end{syntax}
+% Sets the \LaTeXe{}/plain \TeX{} conditional |\if|\meta{name}
+% (generated by \tn{newif}) to be \texttt{true} or \texttt{false}.
+% \end{function}
+%
+% \begin{function}[added = 2021-05-10]{\legacy_if_set:nn, \legacy_if_gset:nn}
+% \begin{syntax}
+% \cs{legacy_if_set:nn} \Arg{name} \Arg{boolexpr}
+% \end{syntax}
+% Sets the \LaTeXe{}/plain \TeX{} conditional |\if|\meta{name}
+% (generated by \tn{newif}) to the result of evaluating the
+% \meta{boolean expression}.
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
@@ -91,6 +113,40 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}
+% {
+% \legacy_if_set_true:n, \legacy_if_set_false:n,
+% \legacy_if_gset_true:n, \legacy_if_gset_false:n
+% }
+% A friendly wrapper.
+% \begin{macrocode}
+\cs_new_protected:Npn \legacy_if_set_true:n #1
+ { \cs_set_eq:cN { if#1 } \if_true: }
+\cs_new_protected:Npn \legacy_if_set_false:n #1
+ { \cs_set_eq:cN { if#1 } \if_false: }
+\cs_new_protected:Npn \legacy_if_gset_true:n #1
+ { \cs_gset_eq:cN { if#1 } \if_true: }
+\cs_new_protected:Npn \legacy_if_gset_false:n #1
+ { \cs_gset_eq:cN { if#1 } \if_false: }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\legacy_if_set:nn, \legacy_if_gset:nn}
+% A more elaborate wrapper.
+% \begin{macrocode}
+\cs_new_protected:Npn \legacy_if_set:nn #1#2
+ {
+ \bool_if:nTF {#2} \legacy_if_set_true:n \legacy_if_set_false:n
+ {#1}
+ }
+\cs_new_protected:Npn \legacy_if_gset:nn #1#2
+ {
+ \bool_if:nTF {#2} \legacy_if_gset_true:n \legacy_if_gset_false:n
+ {#1}
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</package>
% \end{macrocode}
diff --git a/l3kernel/testfiles/m3legacy001.lvt b/l3kernel/testfiles/m3legacy001.lvt
new file mode 100644
index 000000000..a4139f37a
--- /dev/null
+++ b/l3kernel/testfiles/m3legacy001.lvt
@@ -0,0 +1,56 @@
+%
+% Copyright (C) 2021 The LaTeX Project
+%
+
+\documentclass{minimal}
+\input{regression-test}
+% Leave some padding so that the line numbers
+% of the tests don't change later on.
+
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation , log-functions }
+\ExplSyntaxOff
+
+\begin{document}
+\START
+\AUTHOR{Bruno Le Floch}
+\ExplSyntaxOn
+
+\def\Atrue{\let\ifA=\iftrue}
+\def\Afalse{\let\ifA=\iffalse}
+\Afalse
+\def\Btrue{\let\ifB=\iftrue}
+\def\Bfalse{\let\ifB=\iffalse}
+\Btrue
+\def\Ctrue{\let\ifC=\iftrue}
+\def\Cfalse{\let\ifC=\iffalse}
+\Ctrue
+
+\TEST { legacy~if }
+ {
+ \legacy_if:nTF { A } { \ERROR } { \FALSE }
+ \legacy_if:nF { B } { \ERROR }
+ \bool_if:nTF
+ { \legacy_if_p:n { A } || ! \legacy_if_p:n { B } }
+ { \ERROR } { \FALSE }
+ }
+
+\TEST { legacy~set }
+ {
+ \TYPE { \meaning \ifC }
+ \group_begin:
+ \legacy_if_set:nn { C } { \legacy_if_p:n { A } && \legacy_if_p:n { B } }
+ \TYPE { \meaning \ifC }
+ \group_end:
+ \TYPE { \meaning \ifC }
+ \group_begin:
+ \legacy_if_gset_false:n { C }
+ \TYPE { \meaning \ifC }
+ \group_end:
+ \TYPE { \meaning \ifC }
+ }
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\END
diff --git a/l3kernel/testfiles/m3pdf001.tlg b/l3kernel/testfiles/m3legacy001.tlg
similarity index 81%
copy from l3kernel/testfiles/m3pdf001.tlg
copy to l3kernel/testfiles/m3legacy001.tlg
index 42e0bd402..fe15927d9 100644
--- a/l3kernel/testfiles/m3pdf001.tlg
+++ b/l3kernel/testfiles/m3legacy001.tlg
@@ -1,20 +1,18 @@
This is a generated file for the LaTeX (2e + expl3) validation system.
Don't change this file in any respect.
-Author: Ulrike Fischer, Joseph Wright
+Author: Bruno Le Floch
============================================================
-TEST 1: Version comparison
+TEST 1: legacy if
============================================================
-TRUE
FALSE
-TRUE
FALSE
-FALSE
-TRUE
============================================================
============================================================
-TEST 2: Version
+TEST 2: legacy set
============================================================
-1.5
-1
-5
+\iftrue
+\iffalse
+\iftrue
+\iffalse
+\iffalse
============================================================
More information about the latex3-commits
mailing list.