[latex3-commits] [git/LaTeX3-latex3-latex2e] gh373: The command has to be parameterless for \@if at newcommand (c464e548)

PhelypeOleinik tex.phelype at gmail.com
Thu Aug 20 19:45:45 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh373
Link       : https://github.com/latex3/latex2e/commit/c464e548eb25e46fdae06fd9bd909abd23ff1a3f

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

commit c464e548eb25e46fdae06fd9bd909abd23ff1a3f
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Thu Aug 20 14:45:45 2020 -0300

    The command has to be parameterless for \@if at newcommand


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

c464e548eb25e46fdae06fd9bd909abd23ff1a3f
 base/ltdefns.dtx | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/base/ltdefns.dtx b/base/ltdefns.dtx
index 1c7dd3b0..c41860ed 100644
--- a/base/ltdefns.dtx
+++ b/base/ltdefns.dtx
@@ -1350,10 +1350,7 @@
 %   \cs{NewCommandCopy} in a ``normal'' macro.
 %    \begin{macrocode}
 \def\robust at command@act#1#2#3#4{%
-  \begingroup
-    \escapechar=`\\
-  \expandafter\endgroup\expandafter
-  \robust at command@act at chk@args\meaning#2:->\@nil
+  \robust at command@chk at safe#2%
     {\expandafter\robust at command@act at loop
        \expandafter#2%
          #1{\@nnil\@nnil}%
@@ -1390,8 +1387,14 @@
 \def\robust at command@act at end#1#2{#1#2}
 %    \end{macrocode}
 %
+% \begin{macro}{\robust at command@chk at safe}
 % \begin{macro}{\robust at command@act at chk@args}
 %    \begin{macrocode}
+\def\robust at command@chk at safe#1{%
+  \begingroup
+    \escapechar=`\\
+  \expandafter\endgroup\expandafter
+  \robust at command@act at chk@args\meaning#1:->\@nil}
 \def\robust at command@act at chk@args#1:->#2\@nil{%
   \@expl at str@if at eq@@nnTF{#1}{macro}%
     {\@firstoftwo}%
@@ -1405,6 +1408,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 %
 % \subsubsection{Copying robust commands}
@@ -1644,10 +1648,12 @@
     \expandafter\noexpand\csname\@expl at cs@to at str@@N#2 \endcsname}%
   \reserved at a}
 \def\copy at kernel@robust at command#1#2{%
-  \@if at newcommand#2%
-    {\@copy at newcommand}%
+  \robust at command@chk at safe#2%
+    {\@if at newcommand#2%
+       {\@copy at newcommand}%
+       {\declare at commandcopy@let}}
     {\declare at commandcopy@let}%
-    #1#2}
+  #1#2}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1677,8 +1683,10 @@
   \expandafter\show at kernel@robust at command
     \csname\@expl at cs@to at str@@N#1 \endcsname}
 \def\show at kernel@robust at command#1{%
-  \@if at newcommand#1%
-    {\@show at newcommand}%
+  \robust at command@chk at safe#1%
+    {\@if at newcommand#1%
+       {\@show at newcommand}%
+       {\show}}%
     {\show}%
   #1}
 %    \end{macrocode}
@@ -1692,6 +1700,10 @@
 %   \verb*=\@protected at testopt\cmd\\cmd{<opt>}=.  To check that we look at the
 %   first three tokens in the expansion of \verb=\cmd=, and return true or false
 %   accordingly.
+%
+%   This test \emph{requires} that the command be a parameterless macro,
+%   otherwise it will not work (and probably break).  This is ensured with
+%   \cs{robust at command@chk at safe} before calling \cs{@if at newcommand}.
 %    \begin{macrocode}
 \def\@if at newcommand#1{%
   \edef\reserved at a{%





More information about the latex3-commits mailing list.