summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-10-23 21:51:29 +0000
committerKarl Berry <karl@freefriends.org>2019-10-23 21:51:29 +0000
commitdd06d4496374d098aa8082c27f4ebfe8ab0bdab1 (patch)
treef7a3b30a06ba59b8753a22dd03ce4bb59ca2411c /Master/texmf-dist/source/latex/l3kernel/l3file.dtx
parenteeab732aae7905ef02132ea5cd0571c63a420726 (diff)
l3kernel (22oct19)
git-svn-id: svn://tug.org/texlive/trunk@52510 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3file.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3file.dtx43
1 files changed, 40 insertions, 3 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
index 6f39937f85d..19807253e38 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
@@ -44,7 +44,7 @@
% }^^A
% }
%
-% \date{Released 2019-10-14}
+% \date{Released 2019-10-21}
%
% \maketitle
%
@@ -69,6 +69,11 @@
% 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 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 start of the name only.
+%
% \section{Input--output stream management}
%
% As \TeX{} engines have a limited number of input and output streams, direct
@@ -2362,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
@@ -2369,8 +2378,11 @@
% \begin{macrocode}
\cs_new:Npn \__kernel_file_name_sanitize:n #1
{
- \__kernel_file_name_expand_loop:w #1
- \q_recursion_tail \q_recursion_stop
+ \exp_args:Ne \__kernel_file_name_trim_spaces:n
+ {
+ \__kernel_file_name_expand_loop:w #1
+ \q_recursion_tail \q_recursion_stop
+ }
}
\cs_new:Npn \__kernel_file_name_expand_loop:w #1 \q_recursion_stop
{
@@ -2419,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}