[latex3-commits] [git/LaTeX3-latex3-latex2e] gh479: Simplify checking for \ExplSyntaxOn/Off (cf7117ce)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Mar 22 20:59:23 CET 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh479
Link       : https://github.com/latex3/latex2e/commit/cf7117ce92df43d716fd76dfc9a72b0c5fb972e7

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

commit cf7117ce92df43d716fd76dfc9a72b0c5fb972e7
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Mar 22 16:59:23 2021 -0300

    Simplify checking for \ExplSyntaxOn/Off


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

cf7117ce92df43d716fd76dfc9a72b0c5fb972e7
 base/latexrelease.dtx | 26 ++++++++++++++++----------
 base/ltcmd.dtx        |  2 --
 base/lthooks.dtx      |  2 --
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/base/latexrelease.dtx b/base/latexrelease.dtx
index 6bca5462..cb4e0c31 100644
--- a/base/latexrelease.dtx
+++ b/base/latexrelease.dtx
@@ -419,7 +419,6 @@
 % be used in the \LaTeX{} kernel, taking \pkg{lthooks} as example:
 % \begin{verbatim}
 % %<*2ekernel|latexrelease>
-% %<latexrelease>\@ifundefined{ExplSyntaxOn}{}
 % \ExplSyntaxOn
 % %<latexrelease>\NewModuleRelease{lthooks}{2020/10/01}
 % \NewDocumentCommand \NewHook { m }
@@ -438,7 +437,6 @@
 % %<latexrelease>\cs_undefine:N \NewHook
 % %<latexrelease>\cs_undefine:N \AddToHook
 % %<latexrelease>\EndModuleRelease
-% %<latexrelease>\@ifundefined{ExplSyntaxOff}{}
 % \ExplSyntaxOff
 % %</2ekernel|latexrelease>
 % \end{verbatim}
@@ -454,15 +452,10 @@
 % into \pkg{latexrelease}).
 %
 % Note that in the example above, \cs{ExplSyntaxOn} and
-% \cs{ExplSyntaxOff} were added \emph{outside} the module code, because,
+% \cs{ExplSyntaxOff} were added \emph{outside} the module code because,
 % as discussed above, sometimes the code outside \cs{IncludeInRelease}
 % guards may be skipped, but not the code inside them, and in that case
-% the catcodes would be wrong when defining the code.  Furthermore,
-% their existence needs to be checked (see the \cs{@ifundefined} lines
-% above them) when in \pkg{latexrelease} mode, in case a new
-% \file{latexrelease.sty} is being used in a pre-2020-02-02 release to
-% roll back/forth to a date also before 2020-02-02 (when \pkg{expl3} was
-% included in the kernel).
+% the catcodes would be wrong when defining the code.
 %
 % \section{fixltx2e}
 %
@@ -603,6 +596,14 @@ of this package available from CTAN}
 %
 % \subsection{Ignoring \texttt{\string_new} errors when rolling back}
 %
+% Enforce \cs{ExplSyntaxOn} and \cs{ExplSyntaxOff} to be \cs{relax} in
+% \pkg{latexrelease} if they are not yet defined.  They are later
+% restored to be undefined if needed.
+%    \begin{macrocode}
+\csname ExplSyntaxOn\endcsname
+\csname ExplSyntaxOff\endcsname
+%    \end{macrocode}
+%
 % \changes{v1.0m}{2021/03/18}
 %         {Make \texttt{\string_new} definitions harmless}
 %    \begin{macrocode}
@@ -697,10 +698,15 @@ of this package available from CTAN}
 %
 % \subsection{Undoing the temp modifications}
 %
+% If \cs{ExplSyntaxOn} exists (defined and not equal \cs{relax}), then
+% use the \pkg{expl3} restore code, otherwise restore \cs{ExplSyntaxOn}
+% and \cs{ExplSyntaxOff} to be undefined.
 %    \begin{macrocode}
 %<*latexrelease-finish>
 \@ifundefined{ExplSyntaxOn}%
-  {\@gobble}%
+  {\let\ExplSyntaxOn\@undefined
+   \let\ExplSyntaxOff\@undefined
+   \@gobble}%
   {\ExplSyntaxOn
    \@firstofone}%
   {%
diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 36071a99..03f577d4 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -87,7 +87,6 @@
 %<*2ekernel|latexrelease>
 %<latexrelease>\edef\@latexrelease at catcode@null{\the\catcode`\^^@ }
 %<latexrelease>\catcode`\^^@=12
-%<latexrelease>\@ifundefined{ExplSyntaxOn}{}
 \ExplSyntaxOn
 %<latexrelease>\NewModuleRelease{ltcmd}{2020/10/01}%
 %    \end{macrocode}
@@ -4012,7 +4011,6 @@
 %<latexrelease>                 {ltcmd}{Document~commands}%
 %<latexrelease>
 %<latexrelease>\EndModuleRelease
-%<latexrelease>\@ifundefined{ExplSyntaxOff}{}
 \ExplSyntaxOff
 %<latexrelease>\@ifundefined{ExplSyntaxOff}{}{\latexrelease at postexpl}
 %<latexrelease>\catcode`\^^@=\@latexrelease at catcode@null\relax
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index eec3d83d..1e1d9200 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -1716,7 +1716,6 @@
 %         {Use \cs{NewModuleRelease}.}
 %    \begin{macrocode}
 %<*2ekernel|latexrelease>
-%<latexrelease>\@ifundefined{ExplSyntaxOn}{}
 \ExplSyntaxOn
 %<latexrelease>\NewModuleRelease{lthooks}{2020/10/01}
 %    \end{macrocode}
@@ -4505,7 +4504,6 @@
 %<latexrelease>\long\def \IfHookEmptyTF #1#2#3{#2}
 %<latexrelease>
 %<latexrelease>\EndModuleRelease
-%<latexrelease>\@ifundefined{ExplSyntaxOff}{}
 \ExplSyntaxOff
 %</2ekernel|latexrelease>
 %    \end{macrocode}





More information about the latex3-commits mailing list.