[latex3-commits] [git/LaTeX3-latex3-latex2e] gh373: Don't break with \par (94d4817a)
PhelypeOleinik
tex.phelype at gmail.com
Fri Aug 21 07:09:30 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : gh373
Link : https://github.com/latex3/latex2e/commit/94d4817ac8181bb2f99e46508170320868c9a314
>---------------------------------------------------------------
commit 94d4817ac8181bb2f99e46508170320868c9a314
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date: Fri Aug 21 02:09:30 2020 -0300
Don't break with \par
Mostly because of \ShowCommand, because \DeclareRobustCommand doesn't like \par either
>---------------------------------------------------------------
94d4817ac8181bb2f99e46508170320868c9a314
base/ltdefns.dtx | 36 ++++++++++++++++++------------------
base/testfiles/github-0239.lvt | 11 +++++++++++
base/testfiles/github-0239.tlg | 10 ++++++++++
base/testfiles/github-0373.lvt | 6 ++++++
base/testfiles/github-0373.tlg | 8 ++++++++
5 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/base/ltdefns.dtx b/base/ltdefns.dtx
index ae9febb2..bd1f0f1a 100644
--- a/base/ltdefns.dtx
+++ b/base/ltdefns.dtx
@@ -1389,7 +1389,7 @@
% Breaking Badly, and as a bonus, this speeds up the process in case we used
% \cs{NewCommandCopy} in a ``normal'' macro.
% \begin{macrocode}
-\def\robust at command@act#1#2#3#4{%
+\long\def\robust at command@act#1#2#3#4{%
\robust at command@chk at safe#2%
{\expandafter\robust at command@act at loop
\expandafter#2%
@@ -1397,7 +1397,7 @@
\robust at command@act at end}%
{\robust at command@act at end}%
{#3}{#4}}%
-\def\robust at command@act at loop#1#2{\robust at command@act at loop@aux#1#2}
+\long\def\robust at command@act at loop#1#2{\robust at command@act at loop@aux#1#2}
% \end{macrocode}
%
% If \cs{robust at command@act at chk@args} branched to false, then
@@ -1407,14 +1407,14 @@
% \cs{robust at command@act at do} is used to execute \meta{act-type-$n$} on the
% \meta{act-arg}, otherwise the loop resumes with the next item.
% \begin{macrocode}
-\def\robust at command@act at loop@aux#1#2#3{%
+\long\def\robust at command@act at loop@aux#1#2#3{%
\ifx\@nnil#2%
\else
#2{#1}%
{\robust at command@act at do{#3}}%
{\expandafter\robust at command@act at loop\expandafter#1}%
\fi}
-\def\robust at command@act at do#1%
+\long\def\robust at command@act at do#1%
\fi#2%
\robust at command@act at end#3#4{%
\fi
@@ -1424,13 +1424,13 @@
% If the end is reached and no action was taken, then do
% \meta{fallback-action}\meta{act-arg}.
% \begin{macrocode}
-\def\robust at command@act at end#1#2{#1#2}
+\long\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{%
+\long\def\robust at command@chk at safe#1{%
\begingroup
\escapechar=`\\
\expandafter\endgroup\expandafter
@@ -1511,7 +1511,7 @@
% earlier, with \cs{@declarecommandcopylisthook} as the \meta{action-list} and
% \cs{declare at commandcopy@let} as the \meta{fallback-action}.
% \begin{macrocode}
-\def\declare at commandcopy#1#2#3#4{%
+\long\def\declare at commandcopy#1#2#3#4{%
\edef\reserved at a{\@expl at cs@to at str@@N#3}%
\@ifundefined\reserved at a{#1}{#2}%
{\robust at command@act
@@ -1534,7 +1534,7 @@
% The initial definition of \cs{@declarecommandcopylisthook} contains the
% tests for the two types of robust command in the kernel.
% \begin{macrocode}
-\def\declare at commandcopy@let#1#2{\let#1=#2\relax}
+\long\def\declare at commandcopy@let#1#2{\let#1=#2\relax}
% \end{macrocode}
% \end{macro}
%
@@ -1577,7 +1577,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\def\ShowCommand#1{%
+\long\def\ShowCommand#1{%
\robust at command@act
\@showcommandlisthook#1%
\show#1}
@@ -1632,7 +1632,7 @@
% \verb=\cmd= is exactly \verb*=\protect\cmd =.
%
% \begin{macrocode}
-\def\@if at DeclareRobustCommand#1{%
+\long\def\@if at DeclareRobustCommand#1{%
\begingroup
\escapechar=`\\
\edef\reserved at a{\string#1}%
@@ -1666,7 +1666,7 @@
% command. We use \cs{@if at newcommand} to check that and
% \cs{@copy at newcommand} to do the copying.
% \begin{macrocode}
-\def\@copy at DeclareRobustCommand#1#2{%
+\long\def\@copy at DeclareRobustCommand#1#2{%
\begingroup
\escapechar=`\\
\edef\reserved at a{\string#1}%
@@ -1684,7 +1684,7 @@
\expandafter\noexpand\csname\@expl at cs@to at str@@N#1 \endcsname
\expandafter\noexpand\csname\@expl at cs@to at str@@N#2 \endcsname}%
\reserved at a}
-\def\copy at kernel@robust at command#1#2{%
+\long\def\copy at kernel@robust at command#1#2{%
\robust at command@chk at safe#2%
{\@if at newcommand#2%
{\@copy at newcommand}%
@@ -1714,12 +1714,12 @@
% The value of \cs{escapechar} is deliberately not enforced, so
% \cs{ShowCommand} behaves more like \cs{show}.
% \begin{macrocode}
-\def\@show at DeclareRobustCommand#1{%
+\long\def\@show at DeclareRobustCommand#1{%
\typeout{> \string#1=robust macro:}%
\typeout{->\@expl at cs@replacement at spec@@N#1.^^J}%
\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{%
+\long\def\show at kernel@robust at command#1{%
\robust at command@chk at safe#1%
{\@if at newcommand#1%
{\@show at newcommand}%
@@ -1742,7 +1742,7 @@
% 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{%
+\long\def\@if at newcommand#1{%
\edef\reserved at a{%
\noexpand\@protected at testopt
\noexpand#1%
@@ -1763,7 +1763,7 @@
% \verb=\foo= by defining the latter to expand to
% \verb=\@protected at testopt\foo\\foo{<opt>}=.
% \begin{macrocode}
-\def\@copy at newcommand#1#2{%
+\long\def\@copy at newcommand#1#2{%
\edef#1{\noexpand\@protected at testopt
\noexpand#1%
\expandafter\noexpand\csname\@backslashchar\@expl at cs@to at str@@N#1\endcsname
@@ -1784,7 +1784,7 @@
% actual definition, and with the expansion of the command to extract the
% default value of the optional argument.
% \begin{macrocode}
-\def\@show at newcommand#1{%
+\long\def\@show at newcommand#1{%
\typeout{> \string#1=robust macro:}%
\typeout{->\@expl at cs@replacement at spec@@N#1.^^J}%
\expandafter\@show at newcommand@aux
@@ -1808,7 +1808,7 @@
% The extra gymnastics with \cs{showtokens} ensures that \cs{showtokens}
% itself, and the internals of this macro aren't showed in the context lines.
% \begin{macrocode}
-\def\@show at newcommand@aux#1#2{%
+\long\def\@show at newcommand@aux#1#2{%
\typeout{> \string#1=\@expl at cs@prefix at spec@@N#1macro:}%
\edef\reserved at a{%
default \string##1=\expandafter\detokenize\@gobblethree#2.^^J%
diff --git a/base/testfiles/github-0239.lvt b/base/testfiles/github-0239.lvt
index dfaa9002..f64384eb 100644
--- a/base/testfiles/github-0239.lvt
+++ b/base/testfiles/github-0239.lvt
@@ -138,5 +138,16 @@
\DeclareCommandCopy\tmp\goodbreak
{\let\protect\show\tmp}
+% \DeclaraRobustCommand doesn't work...
+% {\DeclareRobustCommand\par{funny \endgraf}%
+{\edef\par{\noexpand\protect\expandafter\noexpand\csname par \endcsname}%
+ \expandafter\def\csname par \endcsname{funny \endgraf}%
+\DeclareCommandCopy\mypar\par
+\let\protect\show\mypar}
+
+{\DeclareRobustCommand\mypar{funny \endgraf}%
+\DeclareCommandCopy\par\mypar
+\let\protect\show\par}
+
\end{document}
diff --git a/base/testfiles/github-0239.tlg b/base/testfiles/github-0239.tlg
index 31277ac5..df6cf072 100644
--- a/base/testfiles/github-0239.tlg
+++ b/base/testfiles/github-0239.tlg
@@ -112,4 +112,14 @@ l. ...{\let\protect\show\myfrac
\tmp ->\protect \tmp
l. ...{\let\protect\show\tmp
}
+> \mypar =macro:
+->funny \endgraf .
+\mypar ->\protect \mypar
+l. ...\let\protect\show\mypar
+ }
+> \par =\long macro:
+->funny \endgraf .
+\par ->\protect \par
+l. ...\let\protect\show\par
+ }
(github-0239.aux)
diff --git a/base/testfiles/github-0373.lvt b/base/testfiles/github-0373.lvt
index dbefea3e..2198b081 100644
--- a/base/testfiles/github-0373.lvt
+++ b/base/testfiles/github-0373.lvt
@@ -138,5 +138,11 @@
\ShowCommand\goodbreak
+% \DeclaraRobustCommand doesn't work...
+% {\DeclareRobustCommand\par{funny \endgraf}%
+{\edef\par{\noexpand\protect\expandafter\noexpand\csname par \endcsname}%
+ \expandafter\def\csname par \endcsname{funny \endgraf}%
+\ShowCommand\par}
+
\end{document}
diff --git a/base/testfiles/github-0373.tlg b/base/testfiles/github-0373.tlg
index 15991739..858421a5 100644
--- a/base/testfiles/github-0373.tlg
+++ b/base/testfiles/github-0373.tlg
@@ -168,4 +168,12 @@ l. ...\ShowCommand\frac
->\par \penalty -500 .
<argument> \goodbreak
l. ...\ShowCommand\goodbreak
+> \par=robust macro:
+->
+.
+> \par =macro:
+->funny \endgraf .
+<argument> \par
+l. ...\ShowCommand\par
+ }
(github-0373.aux)
More information about the latex3-commits
mailing list.