[latex3-commits] [git/LaTeX3-latex3-latex2e] gh530: fix for #530 (68272551)
Frank Mittelbach
frank.mittelbach at latex-project.org
Fri Mar 12 14:33:05 CET 2021
Repository : https://github.com/latex3/latex2e
On branch : gh530
Link : https://github.com/latex3/latex2e/commit/6827255163b978906af9eff77b7ff5ee3eaec038
>---------------------------------------------------------------
commit 6827255163b978906af9eff77b7ff5ee3eaec038
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Fri Mar 12 14:33:05 2021 +0100
fix for #530
>---------------------------------------------------------------
6827255163b978906af9eff77b7ff5ee3eaec038
base/changes.txt | 6 +
base/ltfiles.dtx | 123 ++++++++++++++++-----
.../tlb-latexrelease-rollback-003-often.luatex.tlg | 10 ++
.../tlb-latexrelease-rollback-003-often.tlg | 10 ++
.../tlb-latexrelease-rollback-003-often.xetex.tlg | 10 ++
base/testfiles/tlb-rollback-004-often.luatex.tlg | 5 +
base/testfiles/tlb-rollback-004-often.tlg | 5 +
base/testfiles/tlb-rollback-004-often.xetex.tlg | 5 +
8 files changed, 146 insertions(+), 28 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 6cb6e64f..dfda4c49 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,12 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2021-03-12 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+
+ * ltfiles.dtx (subsection{Safe Input Macros}):
+ Allow for unbalanced conditionals inside arguments #2 and #3
+ of \IfFileExists (gh/530)
+
2021-03-03 Phelype Oleinik <phelype.oleinik at latex-project.org>
* ltclass.dtx:
diff --git a/base/ltfiles.dtx b/base/ltfiles.dtx
index b27f9105..8b0fd78b 100644
--- a/base/ltfiles.dtx
+++ b/base/ltfiles.dtx
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfiles.dtx}
- [2021/01/15 v1.2j LaTeX Kernel (File Handling)]
+ [2021/03/12 v1.2k LaTeX Kernel (File Handling)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfiles.dtx}
@@ -1072,30 +1072,114 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\quote at name}{Quote file names}%
+%<latexrelease>
+%<latexrelease>\let\quote at name\@undefined
+%<latexrelease>\let\quote@@name\@undefined
+%<latexrelease>\let\unquote at name\@undefined
+%<latexrelease>
+%<latexrelease>\long\def \IfFileExists#1#2#3{%
+%<latexrelease> \openin\@inputcheck#1 %
+%<latexrelease> \ifeof\@inputcheck
+%<latexrelease> \ifx\input at path\@undefined
+%<latexrelease> \def\reserved at a{#3}%
+%<latexrelease> \else
+%<latexrelease> \def\reserved at a{\@iffileonpath{#1}{#2}{#3}}%
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \closein\@inputcheck
+%<latexrelease> \edef\@filef at und{#1 }%
+%<latexrelease> \def\reserved at a{#2}%
+%<latexrelease> \fi
+%<latexrelease> \reserved at a}
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+% \end{macrocode}
+%
+%
+%
% \begin{macro}{\IfFileExists@}
% \changes{v0.9b}{1993/12/04}{Macro added}
% \changes{v0.9p}{1994/01/18}{New Definition}
% \changes{v1.0t}{1995/05/25}{(CAR) added \cs{long}}
-% \changes{v1.2d}{2019/10/26}{quote on openin}%
+% \changes{v1.2d}{2019/10/26}{quote on openin}
+% \changes{v1.2k}{2021/03/12}{Allow unbalanced conditionals (gh/530)}
% Argument |#1| is |\@curr at file| so catcode 12 string with no quotes.
+%
+% The original definition picked up arguments |#2| and |#3| in a
+% way that they couldn't contain unbalanced conditionals. A better
+% implementation would have been not to pick up the arguments at
+% all but instead use the usual \cs{@firstoftwo} and
+% \cs{secondoftwo}. However, that changes how |#| is interpreted
+% and so we can't do that nowaways without invalidating a lot of
+% code. Therefore the somewhat curious construction near the end.
% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2021/05/01}%
+%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
\long\def \IfFileExists@#1#2#3{%
\openin\@inputcheck"#1" %
\ifeof\@inputcheck
\ifx\input at path\@undefined
- \def\reserved at a{#3}%
+ \let\reserved at a\@secondoftwo
\else
- \def\reserved at a{\@iffileonpath{#1}{#2}{#3}}%
+ \def\reserved at a{\@iffileonpath{#1}}%
\fi
\else
\closein\@inputcheck
\edef\@filef at und{"#1" }%
- \def\reserved at a{#2}%
+ \let\reserved at a\@firstoftwo
\fi
- \reserved at a}
+% \end{macrocode}
+% This is just there so that any |#| inside |#2| or |#3| needs
+% doubling (as that was the case in the past).
+% \begin{macrocode}
+ \expandafter\def\expandafter\reserved at a
+ \expandafter{\reserved at a{#2}{#3}}%
+\reserved at a}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2019/10/01}%
+%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease>
+%<latexrelease>\long\def \IfFileExists@#1#2#3{%
+%<latexrelease> \openin\@inputcheck"#1" %
+%<latexrelease> \ifeof\@inputcheck
+%<latexrelease> \ifx\input at path\@undefined
+%<latexrelease> \def\reserved at a{#3}%
+%<latexrelease> \else
+%<latexrelease> \def\reserved at a{\@iffileonpath{#1}{#2}{#3}}%
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \closein\@inputcheck
+%<latexrelease> \edef\@filef at und{"#1" }%
+%<latexrelease> \def\reserved at a{#2}%
+%<latexrelease> \fi
+%<latexrelease> \reserved at a}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease>
+%<latexrelease>\let\IfFileExists@\@undefined
+%<latexrelease>
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
% \end{macrocode}
% \end{macro}
%
+%
+%
+%
+%
+%
+%
% \begin{macro}{\@iffileonpath}
% If the file is not found by |\openin|, and |\input at path| is defined,
% look in all the directories specified in |\input at path|.
@@ -1109,6 +1193,10 @@
% \changes{v1.2d}{2019/10/26}{quote on openin}%
% \changes{v1.2f}{2019/11/11}{make \cs{@filef at und} match quoting used on \cs{openin}}%
% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2019/10/01}%
+%<latexrelease> {\@iffileonpath}{Quote file names}
\long\def\@iffileonpath#1{%
\let\reserved at a\@secondoftwo
\expandafter\@tfor\expandafter\reserved at b\expandafter
@@ -1128,28 +1216,7 @@
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease> {\quote at name}{Quote file names}%
-%<latexrelease>
-%<latexrelease>\let\quote at name\@undefined
-%<latexrelease>\let\quote@@name\@undefined
-%<latexrelease>\let\unquote at name\@undefined
-%<latexrelease>
-%<latexrelease>\let\IfFileExists@\@undefined
-%<latexrelease>
-%<latexrelease>\long\def \IfFileExists#1#2#3{%
-%<latexrelease> \openin\@inputcheck#1 %
-%<latexrelease> \ifeof\@inputcheck
-%<latexrelease> \ifx\input at path\@undefined
-%<latexrelease> \def\reserved at a{#3}%
-%<latexrelease> \else
-%<latexrelease> \def\reserved at a{\@iffileonpath{#1}{#2}{#3}}%
-%<latexrelease> \fi
-%<latexrelease> \else
-%<latexrelease> \closein\@inputcheck
-%<latexrelease> \edef\@filef at und{#1 }%
-%<latexrelease> \def\reserved at a{#2}%
-%<latexrelease> \fi
-%<latexrelease> \reserved at a}
+%<latexrelease> {\quote at name}{Quote file names}
%<latexrelease>
%<latexrelease>\long\def\@iffileonpath#1{%
%<latexrelease> \let\reserved at a\@secondoftwo
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
index d09bf9e0..a6a9f968 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
@@ -111,6 +111,11 @@ Skipping: [....-..-..] Spaces in file names and hooks on input line ....
Applying: [....-..-..] Spaces in file names on input line ....
Skipping: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Skipping: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Skipping: [....-..-..] Don't lose the file name on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
@@ -605,6 +610,11 @@ Applying: [....-..-..] Spaces in file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
LaTeX Info: Redefining \IfFileExists on input line ....
Already applied: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Already applied: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Already applied: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
index cca4381b..af78001b 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
@@ -105,6 +105,11 @@ Skipping: [....-..-..] Spaces in file names and hooks on input line ....
Applying: [....-..-..] Spaces in file names on input line ....
Skipping: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Skipping: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Skipping: [....-..-..] Don't lose the file name on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
@@ -589,6 +594,11 @@ Applying: [....-..-..] Spaces in file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
LaTeX Info: Redefining \IfFileExists on input line ....
Already applied: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Already applied: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Already applied: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
index 919b01d6..70e594a2 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
@@ -105,6 +105,11 @@ Skipping: [....-..-..] Spaces in file names and hooks on input line ....
Applying: [....-..-..] Spaces in file names on input line ....
Skipping: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Skipping: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Skipping: [....-..-..] Don't lose the file name on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
@@ -598,6 +603,11 @@ Applying: [....-..-..] Spaces in file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
LaTeX Info: Redefining \IfFileExists on input line ....
Already applied: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Already applied: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Already applied: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.luatex.tlg b/base/testfiles/tlb-rollback-004-often.luatex.tlg
index 01486798..ef9881a7 100644
--- a/base/testfiles/tlb-rollback-004-often.luatex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.luatex.tlg
@@ -137,6 +137,11 @@ Applying: [....-..-..] Spaces in file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
LaTeX Info: Redefining \IfFileExists on input line ....
Already applied: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Already applied: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Already applied: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.tlg b/base/testfiles/tlb-rollback-004-often.tlg
index df24dbb6..190cc5cd 100644
--- a/base/testfiles/tlb-rollback-004-often.tlg
+++ b/base/testfiles/tlb-rollback-004-often.tlg
@@ -126,6 +126,11 @@ Applying: [....-..-..] Spaces in file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
LaTeX Info: Redefining \IfFileExists on input line ....
Already applied: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Already applied: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Already applied: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.xetex.tlg b/base/testfiles/tlb-rollback-004-often.xetex.tlg
index f931dec1..9c061b8a 100644
--- a/base/testfiles/tlb-rollback-004-often.xetex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.xetex.tlg
@@ -126,6 +126,11 @@ Applying: [....-..-..] Spaces in file names on input line ....
Applying: [....-..-..] Quote file names on input line ....
LaTeX Info: Redefining \IfFileExists on input line ....
Already applied: [....-..-..] Quote file names on input line ....
+Skipping: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] manage unbalanced conditionals on input line ....
+Already applied: [....-..-..] manage unbalanced conditionals on input line ....
+Applying: [....-..-..] Quote file names on input line ....
+Already applied: [....-..-..] Quote file names on input line ....
Applying: [....-..-..] Don't lose the file name on input line ....
Already applied: [....-..-..] Don't lose the file name on input line ....
Skipping: [....-..-..] Change in file error handling on input line ....
More information about the latex3-commits
mailing list.