Skip to content

Commit

Permalink
Gh1242 (#1242) (#1566)
Browse files Browse the repository at this point in the history
* do not generate a csname unnecessarily

* fix for #1242, probably needs some test changes

* two tests + ltnews entry

* rollback and other tests

* and another one

* Alter error and info message in \DeclareTextComposite;
more tests

* some more tests ...

* and for other engines

* and a typo
  • Loading branch information
FrankMittelbach authored Nov 27, 2024
1 parent d6aa629 commit 69f6390
Show file tree
Hide file tree
Showing 57 changed files with 917 additions and 13 deletions.
11 changes: 9 additions & 2 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ not part of the distribution.
* usrguide.tex:
Add syntax of \Make...case

2024-11-26 Frank Mittelbach <[email protected]>

* ltoutenc.dtx (subsubsection{Declaration commands}):
Log text command/symbol declarations (gh/1242)

Alter error and info message in \DeclareTextComposite

2024-11-26 Frank Mittelbach <[email protected]>

* lthooks.dtx (subsection{Specifying code for next invocation}):
Expand All @@ -34,8 +41,8 @@ not part of the distribution.
2024-11-16 Frank Mittelbach <[email protected]>

* latex209.dtx:
Add low-level marks \mark1, \mark2, and \mark3 to mimic the fact that 2.09 initialized
the mark system with a set of empty marks
Add low-level marks \mark1, \mark2, and \mark3 to mimic the fact
that 2.09 initialized the mark system with a set of empty marks

2024-11-16 Frank Mittelbach <[email protected]>

Expand Down
12 changes: 11 additions & 1 deletion base/doc/ltnews41.tex
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ \subsection{Tab character as a special}
be used in for example a \texttt{v}~specification document command without
additional steps.

\subsection{Logging text command and symbol declarations}

For thirty years the documentation claimed that \cs{DeclareTextSymbol},
\cs{DeclareTextCommand}, and friends log their changes, but in
contrast to their math counterparts they never did. This has now
finally changed.
%
\githubissue{1242}



\section{Bug fixes}

%\subsection{A fix}
Expand Down Expand Up @@ -244,7 +255,6 @@ \subsection{\pkg{multicol}:\ Full support for extended marks}




%\section{Changes to files in the \pkg{cyrillic} category}

\begin{thebibliography}{9}\frenchspacing
Expand Down
64 changes: 56 additions & 8 deletions base/ltoutenc.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
%<*driver>
% \fi
\ProvidesFile{ltoutenc.dtx}
[2024/11/06 v2.1b LaTeX Kernel (font encodings)]
[2024/11/26 v2.1c LaTeX Kernel (font encodings)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltoutenc.dtx}
Expand Down Expand Up @@ -595,8 +595,47 @@
\@dec@text@cmd\providecommand}
% \end{macrocode}
%
%
% \changes{v2.1c}{2024/11/26}{Declare command for logging (gh/1242)}
% \begin{macrocode}
\def\@enc@info#1{%
\GenericInfo{(Encoding)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Encoding Info: \space\space\space#1}}%
% \end{macrocode}
%
% \begin{macrocode}
\def\@dec@text@cmd#1#2#3{%
% \end{macrocode}
% For logging, there are a number of different cases to cater for.
% \changes{v2.1c}{2024/11/26}{Log text command/symbol declarations (gh/1242)}
% \begin{macrocode}
\@enc@info{%
\ifcsname #3\string#2\endcsname
\ifx#1\providecommand
Ignoring declaration for
\else
Redeclaring
\fi
\else
% \end{macrocode}
% In case of \cs{ProvideTextCommand} we are still declaring in this
% case, so we always say declare.
% \begin{macrocode}
Declaring
\fi
text
% \end{macrocode}
% This test distinguishes between commands and symbols:
% \begin{macrocode}
\ifx#1\chardef@text@cmd
symbol
\else
command
\fi
\string#2 (encoding #3)}%
% \end{macrocode}
%
% \begin{macrocode}
\expandafter\def\expandafter#2%
\expandafter{%
\csname#3-cmd\expandafter\endcsname
Expand Down Expand Up @@ -906,9 +945,13 @@
\def\DeclareTextCompositeCommand#1#2#3#4{%
\expandafter\let\expandafter\reserved@a\csname#2\string#1\endcsname
\ifx\reserved@a\relax
% \end{macrocode}
%
% \changes{v2.1c}{2024/11/26}{Alter error and info message}
% \begin{macrocode}
\DeclareTextCommand#1{#2}{%
\@latex@error{\string#1 undeclared in encoding #2}\@eha}%
\@latex@info{Composite with undeclared \string#1 in encoding #2}%
\@latex@error{Text composite \string#1 undeclared in encoding #2}\@eha}%
\@enc@info{Text composite with undeclared \string#1 in encoding #2}%
\expandafter\let\expandafter\reserved@a\csname#2\string#1\endcsname
\fi
\expandafter\expandafter\expandafter\ifx
Expand Down Expand Up @@ -1187,14 +1230,14 @@
\def\UndeclareTextCommand#1#2{%
% \end{macrocode}
% If there is no declaration for the current encoding do nothing.
% (This makes a hash table entry but without e\TeX{} we can't do
% anything about that).
% \changes{v2.1c}{2024/11/26}{Use \cs{ifcsname} to avoid generating a csname}
% \begin{macrocode}
\expandafter\ifx\csname#2\string#1\endcsname\relax
\else
\ifcsname #2\string#1\endcsname
% \end{macrocode}
% Else: throw away that declaration.
% \changes{v2.1c}{2024/11/26}{Log text command change (gh/1242)}
% \begin{macrocode}
\@enc@info{Undeclare text command \string#1 (encoding #2)}%
\global\expandafter\let\csname#2\string#1\endcsname
\@undefined
% \end{macrocode}
Expand Down Expand Up @@ -1227,7 +1270,12 @@
{\csname ?-cmd\expandafter\endcsname\expandafter
#1\csname?\string#1\endcsname}%
\fi
\fi
\else
% \end{macrocode}
% \changes{v2.1c}{2024/11/26}{Log text command change (gh/1242)}
% \begin{macrocode}
\@enc@info{Text command \string#1 (encoding #2) is not declared}%
\fi
}
% \end{macrocode}
%
Expand Down
2 changes: 2 additions & 0 deletions base/testfiles-TU/github-0253.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ l. ...\ShowCommand\=
#1->\@text@composite \TU\= #1\@empty \@text@composite {\add@unicode@accent {"0304}{#1}}.
<recently read> \TU\=
l. ...\csname TU\string\=\endcsname
LaTeX Encoding Info: Redeclaring text command \= (encoding TU) on input line ....
> \==macro:
->\TU-cmd \=\TU\= .
<argument> \=
Expand All @@ -16,6 +17,7 @@ l. ...\ShowCommand\=
#1->\@text@composite \TU\= #1\@empty \@text@composite {\add@unicode@accent {"0300}{#1}}.
<recently read> \TU\=
l. ...\csname TU\string\=\endcsname
LaTeX Encoding Info: Redeclaring text command \= (encoding TU) on input line ....
> \==macro:
->\TU-cmd \=\TU\= .
<argument> \=
Expand Down
4 changes: 4 additions & 0 deletions base/testfiles-legacy/github-0762.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ l. ...\show ^^c3
File: utf8.def ....-..-.. v... UTF-8 support
) (latin9.def
File: latin9.def ....-..-.. v... Input encoding file
LaTeX Encoding Info: Ignoring declaration for text command \textdegree (encoding ?) on input line ....
LaTeX Encoding Info: Ignoring declaration for text command \textcent (encoding ?) on input line ....
LaTeX Encoding Info: Ignoring declaration for text command \textyen (encoding ?) on input line ....
LaTeX Encoding Info: Ignoring declaration for text command \texteuro (encoding ?) on input line ....
)
> ^^c3=macro:
->\~A.
Expand Down
Loading

0 comments on commit 69f6390

Please sign in to comment.