[latex3-commits] [latex3/latex2e] gh1242: fix for #1242, probably needs some test changes (d8cfc3495)

github at latex-project.org github at latex-project.org
Tue Nov 26 21:24:05 CET 2024


Repository : https://github.com/latex3/latex2e
On branch  : gh1242
Link       : https://github.com/latex3/latex2e/commit/d8cfc3495d596b6c6a19c866caa4ac9179025dcb

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

commit d8cfc3495d596b6c6a19c866caa4ac9179025dcb
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Tue Nov 26 21:24:05 2024 +0100

    fix for #1242, probably needs some test changes


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

d8cfc3495d596b6c6a19c866caa4ac9179025dcb
 base/changes.txt               |  5 +++++
 base/ltoutenc.dtx              | 49 ++++++++++++++++++++++++++++++++++++++++--
 base/testfiles/github-1242.lvt | 38 ++++++++++++++++++++++++++++++++
 base/testfiles/github-1242.tlg | 31 ++++++++++++++++++++++++++
 4 files changed, 121 insertions(+), 2 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index eaae54432..fafea3aee 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,11 @@ to completeness or accuracy and it contains some references to files that are
 not part of the distribution.
 ================================================================================
 
+2024-11-26  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
+
+	* ltoutenc.dtx (subsubsection{Declaration commands}):
+	Log text command/symbol declarations (gh/1242)
+
 2024-11-17  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
 	* ltmarks.dtx (section{Public interfaces for packages such as \pkg{multicol}}):
diff --git a/base/ltoutenc.dtx b/base/ltoutenc.dtx
index 335e9bce0..b8f3a4c62 100644
--- a/base/ltoutenc.dtx
+++ b/base/ltoutenc.dtx
@@ -595,8 +595,47 @@
    \@dec at text@cmd\providecommand}
 %    \end{macrocode}
 %
+%    
+% \changes{v2.1c}{2024/11/26}{Declare command for logging (gh/1242)}
+%    \begin{macrocode}
+\def\@enc at info#1{%
+         \GenericInfo{(Encoding)\@spaces\@spaces\@spaces\space\space}%
+                     {LaTeX Encoding Info: \space\space\space#1}}%
+%    \end{macrocode}
+%    
 %    \begin{macrocode}
 \def\@dec at 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 at 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 at text@cmd
+        symbol
+      \else
+        command
+      \fi
+      \string#2 (encoding #3)}%  
+%    \end{macrocode}
+%
+%    \begin{macrocode}
    \expandafter\def\expandafter#2%
       \expandafter{%
          \csname#3-cmd\expandafter\endcsname
@@ -1190,10 +1229,11 @@
 % \changes{v2.1c}{2024/11/26}{Use \cs{ifcsname} to avoid generating a csname}
 %    \begin{macrocode}
   \ifcsname #2\string#1\endcsname
-  \else
 %    \end{macrocode}
 %    Else: throw away that declaration.
+% \changes{v2.1c}{2024/11/26}{Log text command change (gh/1242)}
 %    \begin{macrocode}
+     \@enc at info{Undeclare text command \string#1 (encoding #2)}%
      \global\expandafter\let\csname#2\string#1\endcsname
             \@undefined
 %    \end{macrocode}
@@ -1226,7 +1266,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 at info{Text command \string#1 (encoding #2) is not declared}%
+  \fi
 }
 %    \end{macrocode}
 %
diff --git a/base/testfiles/github-1242.lvt b/base/testfiles/github-1242.lvt
new file mode 100644
index 000000000..f639e2398
--- /dev/null
+++ b/base/testfiles/github-1242.lvt
@@ -0,0 +1,38 @@
+
+\documentclass{article}
+
+\input{test2e}
+\START
+
+\ProvideTextCommand{\baz}{T1}{+++}
+\DeclareTextCommandDefault{\SS}{SZ}
+\DeclareTextSymbol{\ss}{OT1}{28}       % 28 is the slot occupied by \o
+\DeclareTextCommand{\textfiguredash}{OT1}{????}
+
+\ProvideTextCommand{\baz}{T1}{---}
+\DeclareTextCommandDefault{\SS}{SZ}
+\DeclareTextSymbol{\ss}{OT1}{28}       % 28 is the slot occupied by \o
+\DeclareTextCommand{\textfiguredash}{OT1}{????}
+
+\UndeclareTextCommand{\baz}{T1}
+\UndeclareTextCommand{\baz}{OT1}
+
+\UndeclareTextCommand{\foo}{TS1}\tracingnone
+
+
+\OMIT
+\begin{document}
+\TIMO
+\ss\o
+\SS
+\textfiguredash
+
+\baz
+
+\typeout{Command \noexpand\foo remains undefined:}
+\foo
+
+\newpage
+\OMIT
+
+\end{document}
diff --git a/base/testfiles/github-1242.tlg b/base/testfiles/github-1242.tlg
new file mode 100644
index 000000000..9ecedc5ec
--- /dev/null
+++ b/base/testfiles/github-1242.tlg
@@ -0,0 +1,31 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+LaTeX Encoding Info:    Declaring text command \baz (encoding T1) on input line ....
+LaTeX Encoding Info:    Redeclaring text command \SS (encoding ?) on input line ....
+LaTeX Encoding Info:    Redeclaring text symbol \ss (encoding OT1) on input line ....
+LaTeX Encoding Info:    Redeclaring text command \textfiguredash (encoding OT1) on input line ....
+LaTeX Encoding Info:    Ignoring declaration for text command \baz (encoding T1) on input line ....
+LaTeX Encoding Info:    Redeclaring text command \SS (encoding ?) on input line ....
+LaTeX Encoding Info:    Redeclaring text symbol \ss (encoding OT1) on input line ....
+LaTeX Encoding Info:    Redeclaring text command \textfiguredash (encoding OT1) on input line ....
+LaTeX Encoding Info:    Undeclare text command \baz (encoding T1) on input line ....
+LaTeX Encoding Info:    Text command \baz (encoding OT1) is not declared on input line ....
+LaTeX Encoding Info:    Text command \foo (encoding TS1) is not declared on input line ....
+! LaTeX Error: Command \baz unavailable in encoding OT1.
+See the LaTeX manual or LaTeX Companion for explanation.
+Type  H <return>  for immediate help.
+ ...                                              
+l. ...\baz
+Your command was ignored.
+Type  I <command> <return>  to replace it with another command,
+or  <return>  to continue without it.
+Command \foo remains undefined:
+! Undefined control sequence.
+l. ...\foo
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+[1
+]





More information about the latex3-commits mailing list.