[latex3-commits] [latex3/latex2e] develop: guard ifnum characters for #756 (#1295) (b16acc64)

github at latex-project.org github at latex-project.org
Thu Mar 21 15:01:26 CET 2024


Repository : https://github.com/latex3/latex2e
On branch  : develop
Link       : https://github.com/latex3/latex2e/commit/b16acc64f3157e4cc3452915607082c40ef09bef

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

commit b16acc64f3157e4cc3452915607082c40ef09bef
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Thu Mar 21 14:01:26 2024 +0000

    guard ifnum characters for #756 (#1295)
    
    * guard ifnum characters for #756
    
    * Update base/ifthen.dtx
    
    Co-authored-by: Yukai Chou <muzimuzhi at gmail.com>
    
    ---------
    
    Co-authored-by: Yukai Chou <muzimuzhi at gmail.com>


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

b16acc64f3157e4cc3452915607082c40ef09bef
 base/changes.txt               |  6 +++++-
 base/doc/ltnews39.tex          | 15 +++++++++++++++
 base/ifthen.dtx                | 24 +++++++++++++++++++++---
 base/testfiles/github-0756.lvt | 24 ++++++++++++++++++++++++
 base/testfiles/github-0756.tlg |  4 ++++
 5 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 34ce0517..04913bdb 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,7 +6,11 @@ to completeness or accuracy and it contains some references to files that are
 not part of the distribution.
 ================================================================================
 
-2023-12-07 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
+
+2024-03-16  David Carlisle  <David.Carlisle at latex-project.org>
+	* ifthen.dtx guard against active <=> (gh/756)
+
+2024-03-15 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
 	* ltthm.dtx: add link targets to begintheorem commands (hyperref/332)
 
 2024-03-13  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
diff --git a/base/doc/ltnews39.tex b/base/doc/ltnews39.tex
index 43b846de..38fde4fb 100644
--- a/base/doc/ltnews39.tex
+++ b/base/doc/ltnews39.tex
@@ -236,6 +236,11 @@ avoid that an error is written to the log file, but to make it clear
 that this error is harmless and should be ignored we have arranged the
 code so that the error message, if it is issued, takes the following
 format:
+\begingroup
+\makeatletter
+\def\verbatim at font{%
+  \small\ttfamily}
+\makeatletter
 \begin{verbatim}
 ! Infinite glue shrinkage found in box being split.
 <argument> Infinite shrink error above ignored ! 
@@ -245,6 +250,8 @@ Not perfect (especially the somewhat unmotivated \texttt{<argument>}),
 but you can only do so much if error messages and their texts are
 hard-wired in the engine.
 
+\endgroup
+
 So why all this? There are two reasons: we do not lose marks in edge
 cases any longer and perhaps more importantly we are now also reliably
 able to extract marks from arbitrarily boxed data, something that
@@ -280,6 +287,14 @@ well.
 %
 \githubissue{1230}
 
+\subsection{\pkg{ifthen}: guard against active characters in comparisons}
+The \cs{ifthenelse} command now ensures that \verb|<|, \verb|=| and
+\verb|>| are safe
+in numeric tests, even if they have been made active
+(typically by \pkg{babel} language shorthands.)
+%
+\githubissue{756}
+
 \section{Providing \pkg{xtemplate} in the format}
 
 In \LaTeX{} News~32, we described the move of one long-term experimental idea
diff --git a/base/ifthen.dtx b/base/ifthen.dtx
index ef7d8ab3..fe5bea1f 100644
--- a/base/ifthen.dtx
+++ b/base/ifthen.dtx
@@ -30,7 +30,7 @@
 %%
 %% File `ifthen.dtx'.
 %% Copyright (C) 1991 by Leslie Lamport
-%% Copyright (C) 1994-2001 LaTeX project, David Carlisle
+%% Copyright (C) 1994-2024 LaTeX project, David Carlisle
 %%                       all rights reserved.
 %%
 %
@@ -42,7 +42,7 @@
 %<driver>\ProvidesFile{ifthen.drv}
 % \fi
 %         \ProvidesFile{ifthen.dtx}
-          [2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)]
+          [2024/03/16 v1.1e Standard LaTeX ifthen package (DPC)]
 %
 % \iffalse
 %<*driver>
@@ -273,15 +273,30 @@
          \ifx##1\relax\z@\else\expandafter##2##1\fi}}}
 %    \end{macrocode}
 %    \begin{macrocode}
+\begingroup
+\lccode`\~`\> %
+\catcode`\+\active
+\lccode`\+`\< %
+\catcode`\!\active
+\lccode`\!`\= %
+\lowercase{\endgroup
+%    \end{macrocode}
+%    \begin{macrocode}
 \long\def\ifthenelse#1{%
 %    \end{macrocode}
 % \changes{v1.0h}{1994/05/14}{Use \cs{TE at repl}}
+% \changes{v1.1e}{2024/03/16}{replace active \cs{ifnum} syntax}
 %    \begin{macrocode}
   \toks@{#1}%
   \TE at repl\or\TE at or
   \TE at repl\and\TE at and
   \TE at repl\not\TE at neg
 %    \end{macrocode}
+%    \begin{macrocode}
+  \TE at repl~>%
+  \TE at repl+<%
+  \TE at repl!=%
+%    \end{macrocode}
 %
 % \changes{v1.1c}{2001/05/25}{Added \cs{AND}, \cs{OR} and \cs{NOT} as
 %    boolean operators as alternative to the lower case versions
@@ -353,7 +368,10 @@
           \expandafter\@firstoftwo
         \else
           \expandafter\@secondoftwo
-        \fi}
+        \fi}%
+%    \end{macrocode}
+%    \begin{macrocode}
+}
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/base/testfiles/github-0756.lvt b/base/testfiles/github-0756.lvt
new file mode 100644
index 00000000..d867db11
--- /dev/null
+++ b/base/testfiles/github-0756.lvt
@@ -0,0 +1,24 @@
+\documentclass{article}
+
+\input{test2e}
+
+\usepackage{ifthen}
+
+   
+\begin{document}
+
+% babel active characters
+\catcode`\<=\active \def<{X}
+\catcode`\>=\active \def>{X}
+\catcode`\==\active \def={X}
+
+\START
+
+% These should not error.
+
+\ifthenelse{1=0}{\typeout{YES}}{\typeout{NO}}
+
+\ifthenelse{1>0}{\typeout{YES}}{\typeout{NO}}
+
+
+\END
diff --git a/base/testfiles/github-0756.tlg b/base/testfiles/github-0756.tlg
new file mode 100644
index 00000000..d466f520
--- /dev/null
+++ b/base/testfiles/github-0756.tlg
@@ -0,0 +1,4 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+NO
+YES





More information about the latex3-commits mailing list.