[latex3-commits] [latex3/latex2e] gh823: possible fix for #823 (56982ed0)
github at latex-project.org
github at latex-project.org
Tue Nov 7 18:23:24 CET 2023
Repository : https://github.com/latex3/latex2e
On branch : gh823
Link : https://github.com/latex3/latex2e/commit/56982ed0a6172518e1d8002aa03b7ddff22fc66c
>---------------------------------------------------------------
commit 56982ed0a6172518e1d8002aa03b7ddff22fc66c
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Tue Nov 7 18:23:24 2023 +0100
possible fix for #823
>---------------------------------------------------------------
56982ed0a6172518e1d8002aa03b7ddff22fc66c
base/changes.txt | 4 ++++
base/ltcounts.dtx | 14 ++++++++++----
base/testfiles/github-0823.lvt | 32 ++++++++++++++++++++++++++++++++
base/testfiles/github-0823.tlg | 9 +++++++++
4 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 812143d3..e1e3e904 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,10 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================
+2023-11-07 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+ * ltcounts.dtx (subsection{Environment Counter Macros}):
+ In \newcounter do not change \the... if already defined (gh/823)
+
================================================================================
All changes above are only part of the development branch for the next release.
================================================================================
diff --git a/base/ltcounts.dtx b/base/ltcounts.dtx
index 69025fa4..c9dd05c5 100644
--- a/base/ltcounts.dtx
+++ b/base/ltcounts.dtx
@@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltcounts.dtx}
- [2021/07/08 v1.1m LaTeX Kernel (Counters)]
+ [2021/11/07 v1.1n LaTeX Kernel (Counters)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltcounts.dtx}
@@ -305,6 +305,7 @@
% \begin{macro}{\@definecounter}
% \changes{v1.1b}{1995/05/20}{Streamlined code}
% \changes{v1.1c}{1995/05/20}{And do it right}
+% \changes{v1.1n}{2023/11/07}{Do not change \cs{the...} if already defined (gh/823)}
%
% \begin{macrocode}
\def\@definecounter#1{\expandafter\newcount\csname c@#1\endcsname
@@ -312,9 +313,14 @@
\global\expandafter\let\csname cl@#1\endcsname\@empty
\@addtoreset{#1}{@ckpt}%
\global\expandafter\let\csname p@#1\endcsname\@empty
- \expandafter
- \gdef\csname the#1\expandafter\endcsname\expandafter
- {\expandafter\@arabic\csname c@#1\endcsname}}
+ \ifcsname the#1\endcsname
+ \@latex at warning{Command `\string\the#1' already
+ defined -- not changed}%
+ \else
+ \expandafter
+ \gdef\csname the#1\expandafter\endcsname\expandafter
+ {\expandafter\@arabic\csname c@#1\endcsname}%
+ \fi}
% \end{macrocode}
% \end{macro}
%
diff --git a/base/testfiles/github-0823.lvt b/base/testfiles/github-0823.lvt
new file mode 100644
index 00000000..01a4806a
--- /dev/null
+++ b/base/testfiles/github-0823.lvt
@@ -0,0 +1,32 @@
+\documentclass{article}
+
+\input{test2e}
+
+\usepackage{makeidx}
+\makeindex
+
+\START
+
+% bad, but user is not warned
+\newcounter{index}
+\newcounter{bibliography}
+
+\OMIT
+\begin{document}
+\TIMO
+
+test % btw without it nothing goes to idx...
+\index{foobar}
+
+\cite{qqq}
+
+\begin{thebibliography}{99}
+\bibitem{qqq}hmm
+\end{thebibliography}
+
+% lonely \item error
+\printindex
+
+\newpage
+\OMIT
+\end{document}
diff --git a/base/testfiles/github-0823.tlg b/base/testfiles/github-0823.tlg
new file mode 100644
index 00000000..353b7cab
--- /dev/null
+++ b/base/testfiles/github-0823.tlg
@@ -0,0 +1,9 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+\c at index=\count...
+LaTeX Warning: Command `\theindex' already defined -- not changed on input line ....
+\c at bibliography=\count...
+LaTeX Warning: Command `\thebibliography' already defined -- not changed on input line ....
+No file github-0823.ind.
+[1
+]
More information about the latex3-commits
mailing list.