summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltfiles.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/base/ltfiles.dtx')
-rw-r--r--macros/latex-dev/base/ltfiles.dtx129
1 files changed, 119 insertions, 10 deletions
diff --git a/macros/latex-dev/base/ltfiles.dtx b/macros/latex-dev/base/ltfiles.dtx
index 33594a7b91..8e9611d918 100644
--- a/macros/latex-dev/base/ltfiles.dtx
+++ b/macros/latex-dev/base/ltfiles.dtx
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfiles.dtx}
- [2019/11/11 v1.2f LaTeX Kernel (File Handling)]
+ [2020-05-05 v1.2g LaTeX Kernel (File Handling)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfiles.dtx}
@@ -542,15 +542,32 @@
% \begin{macro}{\includeonly}
% \changes{v1.0p}{1995/04/22}{Allow blanks in argument}
% \changes{v1.2a}{2019/07/01}{Support UTF-8}
+% \changes{v1.2g}{2020/05/02}{Improved support for spaces in filenames
+% (gh/217)}
% \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
-%<latexrelease>\IncludeInRelease{2019/10/01}%
+%<latexrelease>\IncludeInRelease{2020/10/01}%
%<latexrelease> {\includeonly}{Spaces in file names}%
\def\includeonly#1{%
\@partswtrue
- \set@curr@file{\zap@space#1 \@empty}%
- \let\@partlist\@curr@file
+% \end{macrocode}
+% Because the argument to |\includeonly| is a comma-separated list
+% of filenames where there may be comma's precedeing some of the
+% filenames or trailing them. Therefore we need to take the list
+% apart, remove the unwanted spaces while leaving the spaces
+% \emph{in} the filenames intact.
+% \begin{macrocode}
+ \let\@partlist\@empty
+ \@for\reserved@a:=#1 \do
+ {
+ \expandafter\set@curr@file@trim@spaces\expandafter{\reserved@a}%
+ \ifx\@partlist\@empty
+ \edef\@partlist{\@curr@file}%
+ \else
+ \edef\@partlist{\@partlist,\@curr@file}%
+ \fi
+ }%
}
\@onlypreamble\includeonly
% \end{macrocode}
@@ -572,21 +589,68 @@
%
% Made |\include| check for being used inside an |\include|'d file, as
% this will not work and cause surprising results.
+% \changes{v1.2g}{2020/05/02}{Get rid of leading and trailing spaces
+% from the filename (gh/217)}
+% \changes{v1.2g}{2020-05-02}{Pass the filename to \cs{@include} by
+% value instead of by reference (gh/217)}
% \begin{macrocode}
\def\include#1{\relax
\ifnum\@auxout=\@partaux
\@latex@error{\string\include\space cannot be nested}\@eha
\else
- \set@curr@file{#1 }%
- \expandafter\@include\@curr@file
+ \set@curr@file@trim@spaces{#1}%
+% \end{macrocode}
+% For historical reasons \cs{@include} expects an argument
+% delimited by a space. This is kept (though uncessary now) to avoid
+% errors in other packages that use \cs{@include} directly.
+% \begin{macrocode}
+ \expandafter\@include\expandafter{\@curr@file} % deliberate space
\fi}
% \end{macrocode}
% \end{macro}
%
%
+%
+% \begin{macro}{\set@curr@file@trim@spaces}
+%
+% For |\include| and |\includeonly| we need a variant that removes
+% any leading and trailing spaces from the filename, while leaving
+% any spaces \emph{inside} the filename intact. In order simplify
+% the implementaion we borrow some code from the \texttt{expl3}
+% language, \textbf{\emph{beware}: this may change unannounced}.
+% \begin{macrocode}
+\def\set@curr@file@trim@spaces#1{%
+ \@expl@tl@trim@spaces@apply@@nN {#1} \set@curr@file }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
% \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2019/10/01}%
+%<latexrelease> {\includeonly}{Spaces in file names}%
+%<latexrelease>
+%<latexrelease>\def\includeonly#1{%
+%<latexrelease> \@partswtrue
+%<latexrelease> \set@curr@file{\zap@space#1 \@empty}%
+%<latexrelease> \let\@partlist\@curr@file
+%<latexrelease> }
+%<latexrelease>
+%<latexrelease>\def\include#1{\relax
+%<latexrelease> \ifnum\@auxout=\@partaux
+%<latexrelease> \@latex@error{\string\include\space cannot be nested}\@eha
+%<latexrelease> \else
+%<latexrelease> \set@curr@file{#1 }%
+%<latexrelease> \expandafter\@include\@curr@file
+%<latexrelease> \fi}
+%<latexrelease>
+%<latexrelease>\let\set@curr@file@trim@spaces\@undefined
+%<latexrelease>\EndIncludeInRelease
+% \end{macrocode}
+%
+% \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease> {\includeonly}{Spaces in file names}%
%<latexrelease>\def\includeonly#1{%
@@ -604,11 +668,20 @@
%
% \begin{macro}{\@include}
+% \changes{v1.2g}{2020/05/02}{Support spaces in filenames by enclosing
+% the names of \texttt{.aux}-files in quotes (gh/217)}
+% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease> {\@include}{Spaces in file names}%
+% \end{macrocode}
+%
% \begin{macrocode}
\def\@include#1 {%
\clearpage
\if@filesw
- \immediate\write\@mainaux{\string\@input{#1.aux}}%
+ \immediate\write\@mainaux{\string\@input{"#1.aux"}}%
\fi
\@tempswatrue
\if@partsw
@@ -620,7 +693,7 @@
\if@tempswa
\let\@auxout\@partaux
\if@filesw
- \immediate\openout\@partaux #1.aux
+ \immediate\openout\@partaux "#1.aux"
\immediate\write\@partaux{\relax}%
\fi
\@input@{#1.tex}%
@@ -640,6 +713,42 @@
\@nameuse{cp@#1}%
\fi
\let\@auxout\@mainaux}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\@include}{Spaces in file names}%
+%<latexrelease>\def\@include#1 {%
+%<latexrelease> \clearpage
+%<latexrelease> \if@filesw
+%<latexrelease> \immediate\write\@mainaux{\string\@input{#1.aux}}%
+%<latexrelease> \fi
+%<latexrelease> \@tempswatrue
+%<latexrelease> \if@partsw
+%<latexrelease> \@tempswafalse
+%<latexrelease> \edef\reserved@b{#1}%
+%<latexrelease> \@for\reserved@a:=\@partlist\do
+%<latexrelease> {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
+%<latexrelease> \fi
+%<latexrelease> \if@tempswa
+%<latexrelease> \let\@auxout\@partaux
+%<latexrelease> \if@filesw
+%<latexrelease> \immediate\openout\@partaux #1.aux
+%<latexrelease> \immediate\write\@partaux{\relax}%
+%<latexrelease> \fi
+%<latexrelease> \@input@{#1.tex}%
+%<latexrelease> \clearpage
+%<latexrelease> \@writeckpt{#1}%
+%<latexrelease> \if@filesw
+%<latexrelease> \immediate\closeout\@partaux
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \deadcycles\z@
+%<latexrelease> \@nameuse{cp@#1}%
+%<latexrelease> \fi
+%<latexrelease> \let\@auxout\@mainaux}
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
% \end{macrocode}
% \end{macro}
%
@@ -698,8 +807,8 @@
% the code in \texttt{utf8.def}). By setting \cs{escapchar} to
% \texttt{-1} we ensure that we don't get a backslash in front. As a
% result we end up with all characters as catcode 12 (plus
-% spaces). We then sometimes add quotes around the contruct
-% (removing any existing inner quotes. Somes we only remove the
+% spaces). We then sometimes add quotes around the construct
+% (removing any existing inner quotes. Sometimes we only remove the
% quotes if they have been supplied by the user. There is clearly
% some room for improvement.
%