[latex3-commits] [git/LaTeX3-latex3-latex2e] gh570: Check for \endfoo with \NewDocumentCommand (fixes #570) (3624d8ef)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri Aug 27 23:51:14 CEST 2021
Repository : https://github.com/latex3/latex2e
On branch : gh570
Link : https://github.com/latex3/latex2e/commit/3624d8ef7c6643c07928ef573ea5ef5dc2f79a42
>---------------------------------------------------------------
commit 3624d8ef7c6643c07928ef573ea5ef5dc2f79a42
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Aug 27 22:51:14 2021 +0100
Check for \endfoo with \NewDocumentCommand (fixes #570)
>---------------------------------------------------------------
3624d8ef7c6643c07928ef573ea5ef5dc2f79a42
base/changes.txt | 7 +++++--
base/ltcmd.dtx | 18 +++++++++++++++---
base/testfiles-ltcmd/ltcmd001.lvt | 2 ++
base/testfiles-ltcmd/ltcmd001.tlg | 7 +++++++
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 48031151..bb5c54d1 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -12,8 +12,11 @@ are not part of the distribution.
Use \msg_... instead of \__kernel_msg... commands for normalized
error and warning commands.
- * ltfilehooks.dtx, lthooks.dtx, ltpara.dtx:
- Internal changes to message names
+ * ltfilehooks.dtx, lthooks.dtx, ltpara.dtx:
+ Internal changes to message names
+
+ * ltcmd.dtx:
+ Check for end-of-enviroment commands
2021-08-20 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 2a442297..fcded30f 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -34,8 +34,8 @@
%%% From File: ltcmd.dtx
%
% \begin{macrocode}
-\def\ltcmdversion{v1.0g}
-\def\ltcmddate{2021-08-07}
+\def\ltcmdversion{v1.0h}
+\def\ltcmddate{2021-08-27}
% \end{macrocode}
%
%<*driver>
@@ -3599,6 +3599,13 @@
with~an~environment~that~already~has~a~definition. \\ \\
The~existing~definition~of~'#1'~will~not~be~altered.
}
+\msg_new:nnnn { cmd } { env-end-already-defined }
+ { End~of~environment~'#1'~already~defined. }
+ {
+ You~have~used~\NewDocumentEnvironment
+ with~an~environment~that~already~has~a~definition~for~'end#1'. \\ \\
+ The~existing~definition~of~'#1'~will~not~be~altered.
+ }
\msg_new:nnnn { cmd } { env-undefined }
{ Environment~'#1'~undefined. }
{
@@ -3887,6 +3894,7 @@
% \end{macro}
%
% \begin{macro}{\NewDocumentEnvironment}
+% \changes{v1.0h}{2021/08/27}{Check for end-of-environment command}
% \begin{macro}{\RenewDocumentEnvironment}
% \begin{macro}{\ProvideDocumentEnvironment}
% \begin{macro}{\DeclareDocumentEnvironment}
@@ -3896,7 +3904,11 @@
{
\cs_if_exist:cTF {#1}
{ \msg_error:nnx { cmd } { env-already-defined } {#1} }
- { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+ {
+ \cs_if_exist:cTF { end #1 }
+ { \msg_error:nnx { cmd } { env-end-already-defined } {#1} }
+ { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+ }
}
\cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4
{
diff --git a/base/testfiles-ltcmd/ltcmd001.lvt b/base/testfiles-ltcmd/ltcmd001.lvt
index 8b0c197a..90ce15e7 100644
--- a/base/testfiles-ltcmd/ltcmd001.lvt
+++ b/base/testfiles-ltcmd/ltcmd001.lvt
@@ -252,6 +252,8 @@
\DeclareDocumentEnvironment { foo } { m o o }
{ (#1) (#2) (#3) } { (#1) (#2) (#3) }
\xparse_show_env:n { foo }
+ \NewDocumentEnvironment { graf } { m o o }
+ { (#1) (#2) (#3) } { (#1) (#2) (#3) }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/base/testfiles-ltcmd/ltcmd001.tlg b/base/testfiles-ltcmd/ltcmd001.tlg
index 8f4614ea..2720be10 100644
--- a/base/testfiles-ltcmd/ltcmd001.tlg
+++ b/base/testfiles-ltcmd/ltcmd001.tlg
@@ -516,6 +516,13 @@ l. ...}
\l__cmd_args_tl }(#1)(#2)(#3).
<recently read> }
l. ...}
+! LaTeX cmd Error: End of environment 'graf' already defined.
+For immediate help type H <return>.
+ ...
+l. ...}
+You have used \NewDocumentEnvironment with an environment that already has a
+definition for 'endgraf'.
+The existing definition of 'graf' will not be altered.
============================================================
============================================================
TEST 12: Environment groups: should show "outside" and 1
More information about the latex3-commits
mailing list.