[latex3-commits] [git/LaTeX3-latex3-latex2e] gh795: Fix cmd type detection (8f99cdeb)
PhelypeOleinik
phelype.oleinik at latex-project.org
Fri Mar 18 21:24:51 CET 2022
Repository : https://github.com/latex3/latex2e
On branch : gh795
Link : https://github.com/latex3/latex2e/commit/8f99cdeb54e7df0b47be8999e6b94c35cc9aef8f
>---------------------------------------------------------------
commit 8f99cdeb54e7df0b47be8999e6b94c35cc9aef8f
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Fri Mar 18 17:24:51 2022 -0300
Fix cmd type detection
fixes #795
>---------------------------------------------------------------
8f99cdeb54e7df0b47be8999e6b94c35cc9aef8f
base/changes.txt | 5 +++++
base/doc/ltnews35.tex | 10 ++++++++++
base/ltcmd.dtx | 23 ++++++++++------------
base/testfiles/github-0795.lvt | 8 ++++++++
.../{github-0060.xetex.tlg => github-0795.tlg} | 2 ++
5 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 5dbde25d..14644f2e 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2022-03-18 Phelype Oleinik <phelype.oleinik at latex-project.org>
+
+ * ltcmd.dtx (subsection{Utilities}):
+ Fix \@@_cmd_type_cases:NnnnnF prematurely expanding macros (gh/795).
+
2022-03-18 Joseph Wright <joseph.wright at latex-project.org>
* ltkeys.dtx:
diff --git a/base/doc/ltnews35.tex b/base/doc/ltnews35.tex
index 3a2f91d7..9bf2279d 100644
--- a/base/doc/ltnews35.tex
+++ b/base/doc/ltnews35.tex
@@ -603,6 +603,16 @@ This has finally been corrected and a warning is now generated also in this case
+\subsection{Fix adding \hook{cmd} hooks to simple macros}
+
+A bug in how \LaTeX{} would detect the type of a command was causing a
+premature forced expansion of such commands, which, depending on their
+definition, could be harmless or could cause severe trouble. This has
+been fixed in the latest release.
+%
+\githubissue{795}
+\sxissue{q/637565}
+
\section{Changes to packages in the \pkg{amsmath} category}
diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index f52b3247..9f560daa 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -34,8 +34,8 @@
%%% From File: ltcmd.dtx
%
% \begin{macrocode}
-\def\ltcmdversion{v1.0k}
-\def\ltcmddate{2022-02-28}
+\def\ltcmdversion{v1.0l}
+\def\ltcmddate{2022-03-18}
% \end{macrocode}
%
%<*driver>
@@ -4097,8 +4097,10 @@
% \begin{macro}{\@@_cmd_type_cases:Nnnnn}
% \changes{v1.0d}{2021/04/19}{Renamed \cs{__cmd_cmd_if_xparse:NTF} to
% \cs{__kernel_cmd_if_xparse:NTF} for cross-module usage}
-% \changes{v1.0d}{2021/07/30}{Added \cs{@@_cmd_type_cases:Nnnnn} for
+% \changes{v1.0d}{2021/07/30}{Added \cs{@@_cmd_type_cases:NnnnnF} for
% \cs{NewCommandCopy} and \cs{ShowCommand} support}
+% \changes{v1.0l}{2022/03/18}{Fix \cs{@@_cmd_type_cases:NnnnnF}
+%" prematurely expanding macros (gh/795)}
% \begin{macro}{\@@_cmd_if_xparse_aux:N}
%
% To determine whether the command is an \pkg{xparse} command check
@@ -4119,20 +4121,15 @@
\exp_args:Nf \tl_if_empty:nT { \cs_argument_spec:N #1 }
{
\token_if_macro:NT #1
- {
- \exp_after:wN \exp_after:wN
- \exp_after:wN \token_to_str:N
- \exp_after:wN \use_i_delimit_by_q_stop:nw
- #1 \scan_stop: \q_stop
- }
+ { \exp_not:N \exp_not:N \exp_not:e { \tl_head:N #1 } }
}
}
{
- { \token_to_str:N \@@_start:nNNnnn } {#2}
- { \token_to_str:N \@@_start_expandable:nNNNNn } {#3}
- { \token_to_str:N \@@_start_env:nnnnn } {#4}
+ { \exp_not:N \@@_start:nNNnnn } {#2}
+ { \exp_not:N \@@_start_expandable:nNNNNn } {#3}
+ { \exp_not:N \@@_start_env:nnnnn } {#4}
{
- \exp_after:wN \token_to_str:N
+ \exp_after:wN \exp_not:N
\cs:w environment~
\exp_last_unbraced:Ne \use_none:nnn
{ \cs_to_str:N #1 } ~end~aux \cs_end:
diff --git a/base/testfiles/github-0795.lvt b/base/testfiles/github-0795.lvt
new file mode 100644
index 00000000..286ed591
--- /dev/null
+++ b/base/testfiles/github-0795.lvt
@@ -0,0 +1,8 @@
+\input test2e
+\START
+\def\test{\typeout{test}\fi}
+\AddToHook{cmd/test/after}{\typeout{hello}}
+\@kernel at after@begindocument
+\if11 % \fi comes from \test
+\test
+\END
diff --git a/base/testfiles/github-0060.xetex.tlg b/base/testfiles/github-0795.tlg
similarity index 90%
copy from base/testfiles/github-0060.xetex.tlg
copy to base/testfiles/github-0795.tlg
index 1d0c6975..5a5b512a 100644
--- a/base/testfiles/github-0060.xetex.tlg
+++ b/base/testfiles/github-0795.tlg
@@ -1,2 +1,4 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
+test
+hello
More information about the latex3-commits
mailing list.