[latex3-commits] [latex3/latex2e] gh0756: guard ifnum characters for #756 (d2374f7f)
github at latex-project.org
github at latex-project.org
Sat Mar 16 13:49:09 CET 2024
Repository : https://github.com/latex3/latex2e
On branch : gh0756
Link : https://github.com/latex3/latex2e/commit/d2374f7fab3f94bdf30a61cd8563521e01abe72e
>---------------------------------------------------------------
commit d2374f7fab3f94bdf30a61cd8563521e01abe72e
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Sat Mar 16 12:49:09 2024 +0000
guard ifnum characters for #756
>---------------------------------------------------------------
d2374f7fab3f94bdf30a61cd8563521e01abe72e
base/changes.txt | 3 +++
base/doc/ltnews39.tex | 15 +++++++++++++++
base/ifthen.dtx | 24 +++++++++++++++++++++---
base/testfiles/github-0756.lvt | 24 ++++++++++++++++++++++++
base/testfiles/github-0756.tlg | 4 ++++
5 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index ec41dc90..b645e375 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,9 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================
+2024-03-16 David Carlisle <David.Carlisle at latex-project.org>
+ * ifthen.dtx guard against active <=> (gh/756)
+
2024-03-13 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* ltfilehook.dtx (subsection{Kernel, class, and package interfaces for \LaTeX{}}):
Clarify that the commands in this section are meant to be usable
diff --git a/base/doc/ltnews39.tex b/base/doc/ltnews39.tex
index e82cb145..eebbe020 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..60537637 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 actif \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.