[latex3-commits] [git/LaTeX3-latex3-latex3] master: Only trim spaces at end of extension (b82336589)

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Oct 20 18:49:54 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/b82336589661f516dec204a2736bb9689b7a004e

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

commit b82336589661f516dec204a2736bb9689b7a004e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sun Oct 20 17:49:54 2019 +0100

    Only trim spaces at end of extension


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

b82336589661f516dec204a2736bb9689b7a004e
 l3kernel/l3file.dtx | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 1157adbbb..e04e2c343 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -69,10 +69,10 @@
 % using |"| tokens if they contain spaces: as a result, |"| tokens are
 % \emph{not} permitted in file names.
 %
-% Spaces are trimmed at the beginning and end of the filename \emph{as given}:
+% Spaces are trimmed at the beginning and end of the file name:
 % this reflects the fact that some file systems do not allow or interact
 % unpredictably with spaces in these positions. When no extension is given,
-% this will trim spaces from the \enquote{stem} of the file name.
+% this will trim spaces from the start of the name only.
 %
 % \section{Input--output stream management}
 %
@@ -2367,6 +2367,10 @@
 % \begin{macro}[rEXP]{\__kernel_file_name_expand_N_type:Nw}
 % \begin{macro}[rEXP]{\__kernel_file_name_expand_group:nw}
 % \begin{macro}[rEXP]{\__kernel_file_name_expand_space:w}
+% \begin{macro}[rEXP]{\__kernel_file_name_trim_spaces:n}
+% \begin{macro}[rEXP]{\__kernel_file_name_trim_spaces:nw}
+% \begin{macro}[rEXP]{\__kernel_file_name_trim_spaces_aux:n}
+% \begin{macro}[rEXP]{\__kernel_file_name_trim_spaces_aux:w}
 %   Expanding the file name without expanding active characters is done
 %   using the same token-by-token approach as for example case changing.
 %   The finale outcome only need be \texttt{e}-type expandable, so there
@@ -2374,7 +2378,7 @@
 %    \begin{macrocode}
 \cs_new:Npn \__kernel_file_name_sanitize:n #1
   {
-    \exp_args:Ne \tl_trim_spaces:n
+    \exp_args:Ne \__kernel_file_name_trim_spaces:n
       {
         \__kernel_file_name_expand_loop:w #1
           \q_recursion_tail \q_recursion_stop
@@ -2427,6 +2431,31 @@
       \exp_not:N \__kernel_file_name_expand_loop:w
     }
 %    \end{macrocode}
+%   Spaces need to be trimmed from the start of the name and from the end of
+%   any extension. However, the name we are passed might not have an extension:
+%   that means we have to look for one. If there is no extension, we still use
+%   the standard trimming function but deliberately prevent any spaces being 
+%   removed at the end.
+%    \begin{macrocode}
+\cs_new:Npn \__kernel_file_name_trim_spaces:n #1
+  { \__kernel_file_name_trim_spaces:nw {#1} #1 . \q_nil . \q_stop }
+\cs_new:Npn \__kernel_file_name_trim_spaces:nw #1#2 . #3 . #4 \q_stop
+  {
+    \quark_if_nil:nTF {#3}
+      {
+        \exp_args:Ne \__kernel_file_name_trim_spaces_aux:n
+          { \tl_trim_spaces:n { #1 \s_stop } }
+      }
+      { \tl_trim_spaces:n {#1} }
+  }
+\cs_new:Npn \__kernel_file_name_trim_spaces_aux:n #1
+  { \__kernel_file_name_trim_spaces_aux:w #1 }
+\cs_new:Npn \__kernel_file_name_trim_spaces_aux:w #1 \s_stop {#1}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
 % \end{macro}
 % \end{macro}
 % \end{macro}





More information about the latex3-commits mailing list