[latex3-commits] [git/LaTeX3-latex3-latex2e] gh239: Cope with \x at protect in robust commands (6732e63a)

PhelypeOleinik tex.phelype at gmail.com
Sat May 9 05:02:32 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh239
Link       : https://github.com/latex3/latex2e/commit/6732e63a9019b53dcb6a3d0f78b04e7a499c2439

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

commit 6732e63a9019b53dcb6a3d0f78b04e7a499c2439
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Sat May 9 00:02:32 2020 -0300

    Cope with \x at protect in robust commands


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

6732e63a9019b53dcb6a3d0f78b04e7a499c2439
 base/ltdefns.dtx               | 20 ++++++++++++++++++--
 base/testfiles/github-0239.tlg | 10 +++++-----
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/base/ltdefns.dtx b/base/ltdefns.dtx
index ae3a6950..b8a51be3 100644
--- a/base/ltdefns.dtx
+++ b/base/ltdefns.dtx
@@ -1434,9 +1434,17 @@
 %
 %    \begin{macrocode}
 \def\IfKernelRobustCommand#1{%
+  \edef\reserved at a{\string#1}%
+  \def\reserved at b{#1}%
+  \edef\reserved at b{\expandafter\strip at prefix\meaning\reserved at b}%
   \begingroup
     \escapechar\m at ne
-    \xdef\@gtempa{\noexpand\protect
+    \xdef\@gtempa{%
+      \ifx\reserved at a\reserved at b
+         \noexpand\x at protect
+         \noexpand#1%
+      \fi
+      \noexpand\protect
       \expandafter\noexpand\csname\string#1 \endcsname}%
   \endgroup
   \ifx\@gtempa#1\relax
@@ -1459,10 +1467,18 @@
 %    \begin{macrocode}
 \def\CopyKernelRobustCommand#1#2{%
   \begingroup
+    \edef\reserved at a{\string#1}%
+    \def\reserved at b{#1}%
+    \edef\reserved at b{\expandafter\strip at prefix\meaning\reserved at b}%
     \escapechar=\m at ne
     \edef\reserved at a{%
   \endgroup
-  \def\noexpand#1{\noexpand\protect
+  \def\noexpand#1{%
+    \ifx\reserved at a\reserved at b
+       \noexpand\x at protect
+       \noexpand#1%
+    \fi
+    \noexpand\protect
     \expandafter\noexpand\csname\string#1 \endcsname}%
   \noexpand\copy at kernel@robust at command
     \expandafter\noexpand\csname\string#1 \endcsname
diff --git a/base/testfiles/github-0239.tlg b/base/testfiles/github-0239.tlg
index 4e7e2894..3bd6de58 100644
--- a/base/testfiles/github-0239.tlg
+++ b/base/testfiles/github-0239.tlg
@@ -21,15 +21,15 @@ Don't change this file in any respect.
 \\+=\long macro:[#1]->boo|
 \\+ =\relax|
 LaTeX Info: Redefining \# on input line ....
-\+=macro:->\x at protect \#\protect \#  |
-\+ =\relax|
+\+=macro:->\x at protect \+\protect \+  |
+\+ =\long macro:#1->boo|
 \\+=\relax|
 \\+ =\relax|
 LaTeX Info: Redefining \$ on input line ....
-\+=macro:->\x at protect \$\protect \$  |
-\+ =\relax|
+\+=macro:->\x at protect \+\protect \+  |
+\+ =macro:->\@protected at testopt \+  \\+  {}|
 \\+=\relax|
-\\+ =\relax|
+\\+ =\long macro:[#1]->boo|
 \+=\protected macro:->\@testopt \\+ |
 \+ =\relax|
 \\+=macro:[#1]->boo|





More information about the latex3-commits mailing list.