[latex3-commits] [git/LaTeX3-latex3-latex2e] gh217: Changes to support filenames with spaces in \include and \includeonly (295c58b3)

Johannes Braams texniek at braams.xs4all.nl
Sat May 2 15:36:56 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh217
Link       : https://github.com/latex3/latex2e/commit/295c58b3a15c32ae1ab656b8e455bc4f1e7aa8c0

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

commit 295c58b3a15c32ae1ab656b8e455bc4f1e7aa8c0
Author: Johannes Braams <texniek at braams.xs4all.nl>
Date:   Sat May 2 15:36:56 2020 +0200

    Changes to support filenames with spaces in \include and \includeonly


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

295c58b3a15c32ae1ab656b8e455bc4f1e7aa8c0
 base/ltexpl.dtx  | 26 ++++++++++++++++++++++++--
 base/ltfiles.dtx | 45 ++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/base/ltexpl.dtx b/base/ltexpl.dtx
index e86b80ac..95d013b6 100644
--- a/base/ltexpl.dtx
+++ b/base/ltexpl.dtx
@@ -33,7 +33,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{ltexpl.dtx}
-             [2020-03-05 v1.1 LaTeX Kernel (expl3-dependent code)]
+             [2020-05-02 v1.2 LaTeX Kernel (expl3-dependent code)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltfinal.dtx}
@@ -75,7 +75,8 @@
 % \changes{v1.0a}{2020/03/02}
 %         {Don't load expl3 if already in the format (gh/295)}
 % \changes{v1.1}{2020/03/05}
-%         {Load xparse.ltx if \cs{NewDocumentCommand} is not defined by expl3.ltx}
+%         {Load xparse.ltx if \cs{NewDocumentCommand} is not defined
+%         by expl3.ltx}
 %    \begin{macrocode}
 \expandafter\ifx\csname tex\string _let:D\endcsname\relax
   \IfFileExists{expl3.ltx}
@@ -114,6 +115,27 @@
 %<*2ekernel>
 %    \end{macrocode}
 %
+%    \subsection{Using expl3 code}
+%
+%    In order to ease the implemantation of some new features in
+%    \LaTeXe\ we may (temporarily) use some coding based on the
+%    expl3-code.
+%    Such macros will eventually vanish and may be changed
+%    unannounced. They are there for internal use in the \LaTeXe\
+%    kernel and are not meant to be used in third-party
+%    packages. These macros will always have \verb|@expl@| in their
+%    name.
+% \changes{v1.2}{2020/05/02}
+%         {Define a macro based on l3 language to support inclusion of
+%         files with space in the name}
+%
+%    \begin{macrocode}
+\ExplSyntaxOn
+\cs_set_eq:NN \@expl at tl@trim at spaces@n \tl_trim_spaces:n
+\cs_set_eq:NN \@expl at exp@args@@Ne   \exp_args:Ne
+\ExplSyntaxOff
+%    \end{macrocode}
+%
 %    \begin{macrocode}
 %</2ekernel>
 %    \end{macrocode}
diff --git a/base/ltfiles.dtx b/base/ltfiles.dtx
index f5ed0f5c..77f0d520 100644
--- a/base/ltfiles.dtx
+++ b/base/ltfiles.dtx
@@ -32,7 +32,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{ltfiles.dtx}
-             [2019/11/11 v1.2f LaTeX Kernel (File Handling)]
+             [2020/05/02 v1.2g LaTeX Kernel (File Handling)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltfiles.dtx}
@@ -542,6 +542,7 @@
 % \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}
 %    \begin{macrocode}
 %</2ekernel>
 %<*2ekernel|latexrelease>
@@ -549,8 +550,23 @@
 %<latexrelease>                 {\includeonly}{Spaces in file names}%
 \def\includeonly#1{%
   \@partswtrue
-  \set at curr@file{\zap at space#1 \@empty}%
-  \let\@partlist\@curr at 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\@part:=#1 \do
+    {
+      \expandafter\set at curr@file at trim@spaces\expandafter{\@part}
+      \ifx\@partlist\@empty
+        \edef\@partlist{\@curr at file}%
+      \else
+        \edef\@partlist{\@partlist,\@curr at file}%
+      \fi
+    }%
   }
 \@onlypreamble\includeonly
 %    \end{macrocode}
@@ -572,13 +588,15 @@
 %
 % 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}
 %    \begin{macrocode}
 \def\include#1{\relax
   \ifnum\@auxout=\@partaux
     \@latex at error{\string\include\space cannot be nested}\@eha
   \else
-  \set at curr@file{#1 }%
-  \expandafter\@include\@curr at file
+    \set at curr@file at trim@spaces{#1}%
+    \@include{\@curr at file}
   \fi}
 %    \end{macrocode}
 % \end{macro}
@@ -604,11 +622,13 @@
 
 %
 % \begin{macro}{\@include}
+% \changes{v1.2g}{2020/05/02}{Support spaces in filenames by enclosing
+%    the names of \texttt{.aux}-files in quotes}
 %    \begin{macrocode}
 \def\@include#1 {%
   \clearpage
   \if at filesw
-    \immediate\write\@mainaux{\string\@input{#1.aux}}%
+    \immediate\write\@mainaux{\string\@input{"#1.aux"}}%
   \fi
   \@tempswatrue
   \if at partsw
@@ -620,7 +640,7 @@
   \if at tempswa
     \let\@auxout\@partaux
     \if at filesw
-      \immediate\openout\@partaux #1.aux
+      \immediate\openout\@partaux "#1.aux"
       \immediate\write\@partaux{\relax}%
     \fi
     \@input@{#1.tex}%
@@ -691,6 +711,7 @@
 
 %  \begin{macro}{\@curr at file}
 %  \begin{macro}{\set at curr@file}
+%  \begin{macro}{\set at curr@file at trim@spaces}
 %
 %   File name handling is done by generating a csname from the
 %   provided file name (which means that UTF-8 octets gets turned into
@@ -732,6 +753,16 @@
   \endgroup
 }
 %    \end{macrocode}
+%    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 \textt{expl3}
+%    language, \textbf{\emph{beware}: this may change unannounced}/
+%    \begin{macrocode}
+\def\set at curr@file at trim@spaces#1{%
+  \@expl at exp@args@@Ne \set at curr@file {\@expl at tl@trim at spaces@n {#1}}} 
+%    \end{macrocode}
+%  \end{macro}
 %  \end{macro}
 %  \end{macro}
 %





More information about the latex3-commits mailing list.