[latex3-commits] [git/LaTeX3-latex3-latex2e] gh587: fix for #587 (ebc39fd6)

Frank Mittelbach frank.mittelbach at latex-project.org
Fri Aug 20 14:04:39 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh587
Link       : https://github.com/latex3/latex2e/commit/ebc39fd66c49f0325a769185be24f197aa9194eb

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

commit ebc39fd66c49f0325a769185be24f197aa9194eb
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Fri Aug 20 14:04:39 2021 +0200

    fix for #587


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

ebc39fd66c49f0325a769185be24f197aa9194eb
 base/changes.txt                                |  5 +++++
 base/doc/ltnews34.tex                           | 15 ++++++++++++++-
 base/lterror.dtx                                | 15 ++++++++++++---
 base/testfiles/github-0587.lvt                  | 16 ++++++++++++++++
 base/testfiles/{tlb0372.tlg => github-0587.tlg} | 16 ++++------------
 5 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 37cf376b..e3846f4f 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.
 ================================================================================
 
+2021-08-20  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
+
+	* lterror.dtx (subsection{Specific errors}):
+	Improve \@badend error message (gh/587)
+
 2021-08-12  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
 	* lthooks.dtx (subsubsection{Generic hooks for all environments}):
diff --git a/base/doc/ltnews34.tex b/base/doc/ltnews34.tex
index 27279dd5..f4553d3b 100644
--- a/base/doc/ltnews34.tex
+++ b/base/doc/ltnews34.tex
@@ -324,6 +324,20 @@ also useful when interpreting the tracing output of the
 \section{Code improvements}
 
 
+
+\subsection{Improve ``\cs{begin} ended by'' error message}
+
+In the past it was possible to get an error message stating something
+like \verb=\begin{foo} ended by \end{foo}=. This could happen when the
+environment name was partly hidden inside a macro, because the test was
+comparing the literal strings while the error message expanded the
+strings fully. This has now been changed to show a more sensible error
+message in this instance.
+%
+\githubissue{587}
+
+
+
 \subsection{Additional Extended Latin characters predefined}
 Some additional characters such as \'k (U+1E131) are now pre-defined and
 will work without needing \verb|\DeclareUnicodeCharacter| declarations.
@@ -392,7 +406,6 @@ will now correctly apply \cs{TrimSpaces} to both arguments.
 
 
 
-
 \section{Changes to packages in the \pkg{graphics} category}
 
 
diff --git a/base/lterror.dtx b/base/lterror.dtx
index 331c0565..10d93a1d 100644
--- a/base/lterror.dtx
+++ b/base/lterror.dtx
@@ -32,7 +32,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{lterror.dtx}
-             [2021/07/11 v1.2s LaTeX Kernel (errors)]
+             [2021/08/20 v1.2t LaTeX Kernel (errors)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{lterror.dtx}
@@ -687,10 +687,19 @@ Type  H <return>  for immediate help.}%
 % RmS 1992/08/24: added code to |\@badend| to display position of
 %               non-matching |\begin|.
 % FMi 1993/01/14: missing space added.
+%
+%    The environment name has to literally match, i.e., what is stored
+%    in \cs{@currenvir} (after one expansion) must match what is
+%    passed to \cs{end} (without expansion). If not we complain. Not
+%    the absolute best solution but at least it avoids getting
+%    \verb=\begin{foo} ended by \end{foo}= which was possible in the
+%    past.
+% \changes{v1.2t}{2021/08/20}{Improve \cs{@badend} error message (gh/587)}
 %    \begin{macrocode}
 \gdef\@badend#1{%
-  \@latex at error{\protect\begin{\@currenvir}\@currenvline
-                     \space ended by \protect\end{#1}}\@eha}
+  \@latex at error{\protect\begin
+     {\detokenize\expandafter{\@currenvir}}\@currenvline
+     \space ended by \protect\end{\detokenize{#1}}}\@eha}
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/base/testfiles/github-0587.lvt b/base/testfiles/github-0587.lvt
new file mode 100644
index 00000000..8696269a
--- /dev/null
+++ b/base/testfiles/github-0587.lvt
@@ -0,0 +1,16 @@
+\documentclass{article}
+
+\input{test2e}
+
+\newenvironment{foo}{\small}{}
+\newenvironment{nokidding?}[1]{\def\myenvname{#1}\begin{#1}}{\end{\myenvname}}
+
+\begin{document}
+
+\START
+
+\begin{nokidding?}{foo}
+  coucouc
+\end{nokidding?}
+
+\end{document}
diff --git a/base/testfiles/tlb0372.tlg b/base/testfiles/github-0587.tlg
similarity index 54%
copy from base/testfiles/tlb0372.tlg
copy to base/testfiles/github-0587.tlg
index c0a0c772..a7efce6b 100644
--- a/base/testfiles/tlb0372.tlg
+++ b/base/testfiles/github-0587.tlg
@@ -1,20 +1,12 @@
 This is a generated file for the LaTeX2e validation system.
 Don't change this file in any respect.
-Author: Frank Mittelbach
-Format: LaTeX2e<1994/06/01>
-Main Class: article
-> \example=\mathchar"10B.
-l. ...\show\example
-> \example=\mathchar"10B.
-l. ...\show\example
-! LaTeX Error: Command `\example' already defined.
+! LaTeX Error: \begin{foo} on input line ... ended by \end{\myenvname }.
 See the LaTeX manual or LaTeX Companion for explanation.
 Type  H <return>  for immediate help.
  ...                                              
-l. ...\DeclareMathSymbol{\example}{0}{letters}{"0B}
+l. ...\end{nokidding?}
 Your command was ignored.
 Type  I <command> <return>  to replace it with another command,
 or  <return>  to continue without it.
-> \example=macro:
-->.
-l. ...\show\example
+[1
+] (github-0587.aux)





More information about the latex3-commits mailing list.